diff options
Diffstat (limited to 'WebCore/bindings')
124 files changed, 6420 insertions, 3109 deletions
diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index 6ba85da..a4cb57d 100644 --- a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -46,6 +46,7 @@ bool RuntimeEnabledFeatures::isGeolocationEnabled = true; bool RuntimeEnabledFeatures::isIndexedDBEnabled = false; bool RuntimeEnabledFeatures::isWebGLEnabled = false; bool RuntimeEnabledFeatures::isPushStateEnabled = false; +bool RuntimeEnabledFeatures::isTouchEnabled = false; #if ENABLE(VIDEO) diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/WebCore/bindings/generic/RuntimeEnabledFeatures.h index 37dceff..1534353 100644 --- a/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -94,6 +94,15 @@ public: static bool pushStateEnabled() { return isPushStateEnabled; } static bool replaceStateEnabled() { return isPushStateEnabled; } +#if ENABLE(TOUCH_EVENTS) + static bool touchEnabled() { return isTouchEnabled; } + static void setTouchEnabled(bool isEnabled) { isTouchEnabled = isEnabled; } + static bool ontouchstartEnabled() { return isTouchEnabled; } + static bool ontouchmoveEnabled() { return isTouchEnabled; } + static bool ontouchendEnabled() { return isTouchEnabled; } + static bool ontouchcancelEnabled() { return isTouchEnabled; } +#endif + private: // Never instantiate. RuntimeEnabledFeatures() { } @@ -106,6 +115,7 @@ private: static bool isIndexedDBEnabled; static bool isWebGLEnabled; static bool isPushStateEnabled; + static bool isTouchEnabled; }; } // namespace WebCore diff --git a/WebCore/bindings/gobject/WebKitDOMBinding.cpp b/WebCore/bindings/gobject/WebKitDOMBinding.cpp index 1f900c3..b8fbdda 100644 --- a/WebCore/bindings/gobject/WebKitDOMBinding.cpp +++ b/WebCore/bindings/gobject/WebKitDOMBinding.cpp @@ -27,8 +27,10 @@ #include "Event.h" #include "EventException.h" #include "HTMLNames.h" +#include "WebKitDOMElementPrivate.h" #include "WebKitDOMNode.h" #include "WebKitDOMNodePrivate.h" +#include "WebKitHTMLElementWrapperFactory.h" namespace WebKit { @@ -66,11 +68,21 @@ void DOMObjectCache::forget(void* objectHandle) static gpointer createWrapper(Node* node) { ASSERT(node); + ASSERT(node->nodeType()); gpointer wrappedNode = 0; - if (node->nodeType()) + switch (node->nodeType()) { + case Node::ELEMENT_NODE: + if (node->isHTMLElement()) + wrappedNode = createHTMLElementWrapper(static_cast<HTMLElement*>(node)); + else + wrappedNode = wrapNode(node); + break; + default: wrappedNode = wrapNode(node); + break; + } return DOMObjectCache::put(node, wrappedNode); } @@ -87,4 +99,23 @@ gpointer kit(Node* node) return createWrapper(node); } +gpointer kit(Element* element) +{ + if (!element) + return 0; + + gpointer kitElement = DOMObjectCache::get(element); + if (kitElement) + return kitElement; + + gpointer wrappedElement; + + if (element->isHTMLElement()) + wrappedElement = createHTMLElementWrapper(static_cast<HTMLElement*>(element)); + else + wrappedElement = wrapElement(element); + + return DOMObjectCache::put(element, wrappedElement); +} + } // namespace WebKit diff --git a/WebCore/bindings/gobject/WebKitDOMBinding.h b/WebCore/bindings/gobject/WebKitDOMBinding.h index f6efa46..d27bdda 100644 --- a/WebCore/bindings/gobject/WebKitDOMBinding.h +++ b/WebCore/bindings/gobject/WebKitDOMBinding.h @@ -28,10 +28,12 @@ namespace WebCore { class Node; +class Element; } // namespace WebCore namespace WebKit { gpointer kit(WebCore::Node* node); +gpointer kit(WebCore::Element* element); class DOMObjectCache { public: diff --git a/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp b/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp new file mode 100644 index 0000000..1513b66 --- /dev/null +++ b/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.cpp @@ -0,0 +1,526 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2008 Luke Kenneth Casson Leighton <lkcl@lkcl.net> + * Copyright (C) 2008 Martin Soto <soto@freedesktop.org> + * Copyright (C) 2010 Igalia S.L. + * + * This file is derived by hand from an automatically generated file. + * Keeping it up-to-date could potentially be done by adding + * a make_names.pl generator, or by writing a separate + * generater which takes JSHTMLElementWrapperFactory.h as input. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebKitHTMLElementWrapperFactory.h" + +#include "HTMLAnchorElement.h" +#include "HTMLAppletElement.h" +#include "HTMLAreaElement.h" +#include "HTMLBRElement.h" +#include "HTMLBaseElement.h" +#include "HTMLBaseFontElement.h" +#include "HTMLBlockquoteElement.h" +#include "HTMLBodyElement.h" +#include "HTMLButtonElement.h" +#include "HTMLCanvasElement.h" +#include "HTMLDListElement.h" +#include "HTMLDirectoryElement.h" +#include "HTMLDivElement.h" +#include "HTMLEmbedElement.h" +#include "HTMLFieldSetElement.h" +#include "HTMLFontElement.h" +#include "HTMLFormElement.h" +#include "HTMLFrameElement.h" +#include "HTMLFrameSetElement.h" +#include "HTMLHRElement.h" +#include "HTMLHeadElement.h" +#include "HTMLHeadingElement.h" +#include "HTMLHtmlElement.h" +#include "HTMLIFrameElement.h" +#include "HTMLImageElement.h" +#include "HTMLInputElement.h" +#include "HTMLIsIndexElement.h" +#include "HTMLLIElement.h" +#include "HTMLLabelElement.h" +#include "HTMLLegendElement.h" +#include "HTMLLinkElement.h" +#include "HTMLMapElement.h" +#include "HTMLMarqueeElement.h" +#include "HTMLMenuElement.h" +#include "HTMLMetaElement.h" +#include "HTMLModElement.h" +#include "HTMLNames.h" +#include "HTMLOListElement.h" +#include "HTMLObjectElement.h" +#include "HTMLOptGroupElement.h" +#include "HTMLOptionElement.h" +#include "HTMLParagraphElement.h" +#include "HTMLParamElement.h" +#include "HTMLPreElement.h" +#include "HTMLQuoteElement.h" +#include "HTMLScriptElement.h" +#include "HTMLSelectElement.h" +#include "HTMLStyleElement.h" +#include "HTMLTableCaptionElement.h" +#include "HTMLTableCellElement.h" +#include "HTMLTableColElement.h" +#include "HTMLTableElement.h" +#include "HTMLTableRowElement.h" +#include "HTMLTableSectionElement.h" +#include "HTMLTextAreaElement.h" +#include "HTMLTitleElement.h" +#include "HTMLUListElement.h" + +#include "webkit/WebKitDOMHTMLAnchorElementPrivate.h" +#include "webkit/WebKitDOMHTMLAppletElementPrivate.h" +#include "webkit/WebKitDOMHTMLAreaElementPrivate.h" +#include "webkit/WebKitDOMHTMLBRElementPrivate.h" +#include "webkit/WebKitDOMHTMLBaseElementPrivate.h" +#include "webkit/WebKitDOMHTMLBaseFontElementPrivate.h" +#include "webkit/WebKitDOMHTMLBlockquoteElementPrivate.h" +#include "webkit/WebKitDOMHTMLBodyElementPrivate.h" +#include "webkit/WebKitDOMHTMLButtonElementPrivate.h" +#include "webkit/WebKitDOMHTMLCanvasElementPrivate.h" +#include "webkit/WebKitDOMHTMLDListElementPrivate.h" +#include "webkit/WebKitDOMHTMLDirectoryElementPrivate.h" +#include "webkit/WebKitDOMHTMLDivElementPrivate.h" +#include "webkit/WebKitDOMHTMLElementPrivate.h" +#include "webkit/WebKitDOMHTMLEmbedElementPrivate.h" +#include "webkit/WebKitDOMHTMLFieldSetElementPrivate.h" +#include "webkit/WebKitDOMHTMLFontElementPrivate.h" +#include "webkit/WebKitDOMHTMLFormElementPrivate.h" +#include "webkit/WebKitDOMHTMLFrameElementPrivate.h" +#include "webkit/WebKitDOMHTMLFrameSetElementPrivate.h" +#include "webkit/WebKitDOMHTMLHRElementPrivate.h" +#include "webkit/WebKitDOMHTMLHeadElementPrivate.h" +#include "webkit/WebKitDOMHTMLHeadingElementPrivate.h" +#include "webkit/WebKitDOMHTMLHtmlElementPrivate.h" +#include "webkit/WebKitDOMHTMLIFrameElementPrivate.h" +#include "webkit/WebKitDOMHTMLImageElementPrivate.h" +#include "webkit/WebKitDOMHTMLInputElementPrivate.h" +#include "webkit/WebKitDOMHTMLIsIndexElementPrivate.h" +#include "webkit/WebKitDOMHTMLLIElementPrivate.h" +#include "webkit/WebKitDOMHTMLLabelElementPrivate.h" +#include "webkit/WebKitDOMHTMLLegendElementPrivate.h" +#include "webkit/WebKitDOMHTMLLinkElementPrivate.h" +#include "webkit/WebKitDOMHTMLMapElementPrivate.h" +#include "webkit/WebKitDOMHTMLMarqueeElementPrivate.h" +#include "webkit/WebKitDOMHTMLMenuElementPrivate.h" +#include "webkit/WebKitDOMHTMLMetaElementPrivate.h" +#include "webkit/WebKitDOMHTMLModElementPrivate.h" +#include "webkit/WebKitDOMHTMLOListElementPrivate.h" +#include "webkit/WebKitDOMHTMLObjectElementPrivate.h" +#include "webkit/WebKitDOMHTMLOptGroupElementPrivate.h" +#include "webkit/WebKitDOMHTMLOptionElementPrivate.h" +#include "webkit/WebKitDOMHTMLParagraphElementPrivate.h" +#include "webkit/WebKitDOMHTMLParamElementPrivate.h" +#include "webkit/WebKitDOMHTMLPreElementPrivate.h" +#include "webkit/WebKitDOMHTMLQuoteElementPrivate.h" +#include "webkit/WebKitDOMHTMLScriptElementPrivate.h" +#include "webkit/WebKitDOMHTMLSelectElementPrivate.h" +#include "webkit/WebKitDOMHTMLStyleElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableCaptionElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableCellElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableColElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableRowElementPrivate.h" +#include "webkit/WebKitDOMHTMLTableSectionElementPrivate.h" +#include "webkit/WebKitDOMHTMLTextAreaElementPrivate.h" +#include "webkit/WebKitDOMHTMLTitleElementPrivate.h" +#include "webkit/WebKitDOMHTMLUListElementPrivate.h" +#include "webkit/webkitdom.h" + +#include <wtf/text/CString.h> + +namespace WebKit { + +using namespace WebCore; +using namespace WebCore::HTMLNames; + +typedef gpointer (*CreateHTMLElementWrapperFunction)(PassRefPtr<HTMLElement>); + +static gpointer createAnchorWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLAnchorElement(static_cast<HTMLAnchorElement*>(element.get())); +} + +static gpointer createAppletWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLAppletElement(static_cast<HTMLAppletElement*>(element.get())); +} + +static gpointer createAreaWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLAreaElement(static_cast<HTMLAreaElement*>(element.get())); +} + +static gpointer createBaseWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLBaseElement(static_cast<HTMLBaseElement*>(element.get())); +} + +static gpointer createBaseFontWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLBaseFontElement(static_cast<HTMLBaseFontElement*>(element.get())); +} + +static gpointer createBlockquoteWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLBlockquoteElement(static_cast<HTMLBlockquoteElement*>(element.get())); +} + +static gpointer createBodyWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLBodyElement(static_cast<HTMLBodyElement*>(element.get())); +} + +static gpointer createBRWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLBRElement(static_cast<HTMLBRElement*>(element.get())); +} + +static gpointer createButtonWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLButtonElement(static_cast<HTMLButtonElement*>(element.get())); +} + +static gpointer createCanvasWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLCanvasElement(static_cast<HTMLCanvasElement*>(element.get())); +} + +static gpointer createTableCaptionWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableCaptionElement(static_cast<HTMLTableCaptionElement*>(element.get())); +} + +static gpointer createTableColWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableColElement(static_cast<HTMLTableColElement*>(element.get())); +} + +static gpointer createModWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLModElement(static_cast<HTMLModElement*>(element.get())); +} + +static gpointer createDirectoryWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLDirectoryElement(static_cast<HTMLDirectoryElement*>(element.get())); +} + +static gpointer createDivWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLDivElement(static_cast<HTMLDivElement*>(element.get())); +} + +static gpointer createDListWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLDListElement(static_cast<HTMLDListElement*>(element.get())); +} + +static gpointer createEmbedWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLEmbedElement(static_cast<HTMLEmbedElement*>(element.get())); +} + +static gpointer createFieldSetWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLFieldSetElement(static_cast<HTMLFieldSetElement*>(element.get())); +} + +static gpointer createFontWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLFontElement(static_cast<HTMLFontElement*>(element.get())); +} + +static gpointer createFormWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLFormElement(static_cast<HTMLFormElement*>(element.get())); +} + +static gpointer createFrameWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLFrameElement(static_cast<HTMLFrameElement*>(element.get())); +} + +static gpointer createFrameSetWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLFrameSetElement(static_cast<HTMLFrameSetElement*>(element.get())); +} + +static gpointer createHeadingWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLHeadingElement(static_cast<HTMLHeadingElement*>(element.get())); +} + +static gpointer createHeadWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLHeadElement(static_cast<HTMLHeadElement*>(element.get())); +} + +static gpointer createHRWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLHRElement(static_cast<HTMLHRElement*>(element.get())); +} + +static gpointer createHtmlWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLHtmlElement(static_cast<HTMLHtmlElement*>(element.get())); +} + +static gpointer createIFrameWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLIFrameElement(static_cast<HTMLIFrameElement*>(element.get())); +} + +static gpointer createImageWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLImageElement(static_cast<HTMLImageElement*>(element.get())); +} + +static gpointer createInputWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLInputElement(static_cast<HTMLInputElement*>(element.get())); +} + +static gpointer createIsIndexWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLIsIndexElement(static_cast<HTMLIsIndexElement*>(element.get())); +} + +static gpointer createLabelWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLLabelElement(static_cast<HTMLLabelElement*>(element.get())); +} + +static gpointer createLegendWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLLegendElement(static_cast<HTMLLegendElement*>(element.get())); +} + +static gpointer createLIWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLLIElement(static_cast<HTMLLIElement*>(element.get())); +} + +static gpointer createLinkWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLLinkElement(static_cast<HTMLLinkElement*>(element.get())); +} + +static gpointer createMapWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLMapElement(static_cast<HTMLMapElement*>(element.get())); +} + +static gpointer createMarqueeWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLMarqueeElement(static_cast<HTMLMarqueeElement*>(element.get())); +} + +static gpointer createMenuWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLMenuElement(static_cast<HTMLMenuElement*>(element.get())); +} + +static gpointer createMetaWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLMetaElement(static_cast<HTMLMetaElement*>(element.get())); +} + +static gpointer createObjectWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLObjectElement(static_cast<HTMLObjectElement*>(element.get())); +} + +static gpointer createOListWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLOListElement(static_cast<HTMLOListElement*>(element.get())); +} + +static gpointer createOptGroupWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLOptGroupElement(static_cast<HTMLOptGroupElement*>(element.get())); +} + +static gpointer createOptionWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLOptionElement(static_cast<HTMLOptionElement*>(element.get())); +} + +static gpointer createParagraphWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLParagraphElement(static_cast<HTMLParagraphElement*>(element.get())); +} + +static gpointer createParamWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLParamElement(static_cast<HTMLParamElement*>(element.get())); +} + +static gpointer createPreWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLPreElement(static_cast<HTMLPreElement*>(element.get())); +} + +static gpointer createQuoteWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLQuoteElement(static_cast<HTMLQuoteElement*>(element.get())); +} + +static gpointer createScriptWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLScriptElement(static_cast<HTMLScriptElement*>(element.get())); +} + +static gpointer createSelectWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLSelectElement(static_cast<HTMLSelectElement*>(element.get())); +} + +static gpointer createStyleWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLStyleElement(static_cast<HTMLStyleElement*>(element.get())); +} + +static gpointer createTableWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableElement(static_cast<HTMLTableElement*>(element.get())); +} + +static gpointer createTableSectionWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableSectionElement(static_cast<HTMLTableSectionElement*>(element.get())); +} + +static gpointer createTableCellWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableCellElement(static_cast<HTMLTableCellElement*>(element.get())); +} + +static gpointer createTextAreaWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTextAreaElement(static_cast<HTMLTextAreaElement*>(element.get())); +} + +static gpointer createTitleWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTitleElement(static_cast<HTMLTitleElement*>(element.get())); +} + +static gpointer createTableRowWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLTableRowElement(static_cast<HTMLTableRowElement*>(element.get())); +} + +static gpointer createUListWrapper(PassRefPtr<HTMLElement> element) +{ + return wrapHTMLUListElement(static_cast<HTMLUListElement*>(element.get())); +} + +gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement> element) +{ + static HashMap<WebCore::AtomicStringImpl*, CreateHTMLElementWrapperFunction> map; + if (map.isEmpty()) { + map.set(aTag.localName().impl(), createAnchorWrapper); + map.set(appletTag.localName().impl(), createAppletWrapper); + map.set(areaTag.localName().impl(), createAreaWrapper); + map.set(baseTag.localName().impl(), createBaseWrapper); + map.set(basefontTag.localName().impl(), createBaseFontWrapper); + map.set(blockquoteTag.localName().impl(), createBlockquoteWrapper); + map.set(bodyTag.localName().impl(), createBodyWrapper); + map.set(brTag.localName().impl(), createBRWrapper); + map.set(buttonTag.localName().impl(), createButtonWrapper); + map.set(canvasTag.localName().impl(), createCanvasWrapper); + map.set(captionTag.localName().impl(), createTableCaptionWrapper); + map.set(colTag.localName().impl(), createTableColWrapper); + map.set(delTag.localName().impl(), createModWrapper); + map.set(dirTag.localName().impl(), createDirectoryWrapper); + map.set(divTag.localName().impl(), createDivWrapper); + map.set(dlTag.localName().impl(), createDListWrapper); + map.set(embedTag.localName().impl(), createEmbedWrapper); + map.set(fieldsetTag.localName().impl(), createFieldSetWrapper); + map.set(fontTag.localName().impl(), createFontWrapper); + map.set(formTag.localName().impl(), createFormWrapper); + map.set(frameTag.localName().impl(), createFrameWrapper); + map.set(framesetTag.localName().impl(), createFrameSetWrapper); + map.set(h1Tag.localName().impl(), createHeadingWrapper); + map.set(headTag.localName().impl(), createHeadWrapper); + map.set(hrTag.localName().impl(), createHRWrapper); + map.set(htmlTag.localName().impl(), createHtmlWrapper); + map.set(iframeTag.localName().impl(), createIFrameWrapper); + map.set(imgTag.localName().impl(), createImageWrapper); + map.set(inputTag.localName().impl(), createInputWrapper); + map.set(isindexTag.localName().impl(), createIsIndexWrapper); + map.set(labelTag.localName().impl(), createLabelWrapper); + map.set(legendTag.localName().impl(), createLegendWrapper); + map.set(liTag.localName().impl(), createLIWrapper); + map.set(linkTag.localName().impl(), createLinkWrapper); + map.set(mapTag.localName().impl(), createMapWrapper); + map.set(marqueeTag.localName().impl(), createMarqueeWrapper); + map.set(menuTag.localName().impl(), createMenuWrapper); + map.set(metaTag.localName().impl(), createMetaWrapper); + map.set(objectTag.localName().impl(), createObjectWrapper); + map.set(olTag.localName().impl(), createOListWrapper); + map.set(optgroupTag.localName().impl(), createOptGroupWrapper); + map.set(optionTag.localName().impl(), createOptionWrapper); + map.set(pTag.localName().impl(), createParagraphWrapper); + map.set(paramTag.localName().impl(), createParamWrapper); + map.set(preTag.localName().impl(), createPreWrapper); + map.set(qTag.localName().impl(), createQuoteWrapper); + map.set(scriptTag.localName().impl(), createScriptWrapper); + map.set(selectTag.localName().impl(), createSelectWrapper); + map.set(styleTag.localName().impl(), createStyleWrapper); + map.set(tableTag.localName().impl(), createTableWrapper); + map.set(tbodyTag.localName().impl(), createTableSectionWrapper); + map.set(tdTag.localName().impl(), createTableCellWrapper); + map.set(textareaTag.localName().impl(), createTextAreaWrapper); + map.set(titleTag.localName().impl(), createTitleWrapper); + map.set(trTag.localName().impl(), createTableRowWrapper); + map.set(ulTag.localName().impl(), createUListWrapper); + map.set(colgroupTag.localName().impl(), createTableColWrapper); + map.set(h2Tag.localName().impl(), createHeadingWrapper); + map.set(h3Tag.localName().impl(), createHeadingWrapper); + map.set(h4Tag.localName().impl(), createHeadingWrapper); + map.set(h5Tag.localName().impl(), createHeadingWrapper); + map.set(h6Tag.localName().impl(), createHeadingWrapper); + map.set(imageTag.localName().impl(), createImageWrapper); + map.set(insTag.localName().impl(), createModWrapper); + map.set(keygenTag.localName().impl(), createSelectWrapper); + map.set(listingTag.localName().impl(), createPreWrapper); + map.set(tfootTag.localName().impl(), createTableSectionWrapper); + map.set(thTag.localName().impl(), createTableCellWrapper); + map.set(theadTag.localName().impl(), createTableSectionWrapper); + map.set(xmpTag.localName().impl(), createPreWrapper); + } + + CreateHTMLElementWrapperFunction createWrapperFunction = + map.get(element->localName().impl()); + if (createWrapperFunction) + return createWrapperFunction(element); + return wrapHTMLElement(element.get()); +} + +} diff --git a/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h b/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h new file mode 100644 index 0000000..2677891 --- /dev/null +++ b/WebCore/bindings/gobject/WebKitHTMLElementWrapperFactory.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2010 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef WebKitHTMLElementWrapperFactory_h +#define WebKitHTMLElementWrapperFactory_h + +#include "HTMLElement.h" +#include "glib-object.h" + +#include <wtf/Forward.h> + +namespace WebCore { +class HTMLElement; +} + +namespace WebKit { +gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement>); +} + +#endif // WebKitHTMLElementWrapperFactory_h diff --git a/WebCore/bindings/js/JSAbstractWorkerCustom.cpp b/WebCore/bindings/js/JSAbstractWorkerCustom.cpp deleted file mode 100644 index 1f843f9..0000000 --- a/WebCore/bindings/js/JSAbstractWorkerCustom.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * Copyright (C) 2009 Apple, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(WORKERS) - -#include "JSAbstractWorker.h" - -#include "AbstractWorker.h" -#include "JSDOMGlobalObject.h" -#include "JSEventListener.h" -#include "JSEventTarget.h" - -using namespace JSC; - -namespace WebCore { - -JSValue JSAbstractWorker::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSAbstractWorker::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -} // namespace WebCore - -#endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index 2e05350..e275397 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -26,7 +26,6 @@ // This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build. #include "GCController.cpp" -#include "JSAbstractWorkerCustom.cpp" #include "JSAttrCustom.cpp" #include "JSAudioConstructor.cpp" #include "JSCDATASectionCustom.cpp" @@ -40,10 +39,7 @@ #include "JSClipboardCustom.cpp" #include "JSConsoleCustom.cpp" #include "JSCoordinatesCustom.cpp" -#include "JSCustomSQLStatementCallback.cpp" #include "JSCustomSQLStatementErrorCallback.cpp" -#include "JSCustomSQLTransactionCallback.cpp" -#include "JSCustomSQLTransactionErrorCallback.cpp" #include "JSCustomVoidCallback.cpp" #include "JSCustomXPathNSResolver.cpp" #include "JSDOMApplicationCacheCustom.cpp" @@ -58,12 +54,10 @@ #include "JSDedicatedWorkerContextCustom.cpp" #include "JSDesktopNotificationsCustom.cpp" #include "JSDocumentCustom.cpp" -#include "JSDocumentFragmentCustom.cpp" #include "JSElementCustom.cpp" #include "JSEventCustom.cpp" #include "JSEventListener.cpp" #include "JSEventSourceConstructor.cpp" -#include "JSEventSourceCustom.cpp" #include "JSEventTarget.cpp" #include "JSExceptionBase.cpp" #include "JSHTMLAllCollectionCustom.cpp" diff --git a/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp b/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp deleted file mode 100644 index 46a7ae5..0000000 --- a/WebCore/bindings/js/JSCustomSQLStatementCallback.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSCustomSQLStatementCallback.h" - -#if ENABLE(DATABASE) - -#include "Frame.h" -#include "JSSQLResultSet.h" -#include "JSSQLTransaction.h" -#include "ScriptExecutionContext.h" -#include <runtime/JSLock.h> -#include <wtf/MainThread.h> - -namespace WebCore { - -using namespace JSC; - -JSCustomSQLStatementCallback::JSCustomSQLStatementCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) -{ -} - -JSCustomSQLStatementCallback::~JSCustomSQLStatementCallback() -{ - callOnMainThread(JSCallbackData::deleteData, m_data); -#ifndef NDEBUG - m_data = 0; -#endif -} - -void JSCustomSQLStatementCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException) -{ - ASSERT(m_data); - ASSERT(context); - - RefPtr<JSCustomSQLStatementCallback> protect(this); - - JSC::JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return; - - ExecState* exec = globalObject->globalExec(); - MarkedArgumentBuffer args; - args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction)); - args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), resultSet)); - - m_data->invokeCallback(args, &raisedException); -} - -} - -#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp index a2ba52a..3026a33 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.cpp @@ -27,42 +27,26 @@ */ #include "config.h" -#include "JSCustomSQLStatementErrorCallback.h" +#include "JSSQLStatementErrorCallback.h" #if ENABLE(DATABASE) #include "Frame.h" -#include "JSCallbackData.h" #include "JSSQLError.h" #include "JSSQLTransaction.h" #include "ScriptExecutionContext.h" #include <runtime/JSLock.h> -#include <wtf/MainThread.h> namespace WebCore { using namespace JSC; -JSCustomSQLStatementErrorCallback::JSCustomSQLStatementErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) -{ -} - -JSCustomSQLStatementErrorCallback::~JSCustomSQLStatementErrorCallback() -{ - callOnMainThread(JSCallbackData::deleteData, m_data); -#ifndef NDEBUG - m_data = 0; -#endif -} - -bool JSCustomSQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error) +bool JSSQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error) { ASSERT(m_data); ASSERT(context); - RefPtr<JSCustomSQLStatementErrorCallback> protect(this); + RefPtr<JSSQLStatementErrorCallback> protect(this); JSC::JSLock lock(SilenceAssertionsOnly); JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); diff --git a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp b/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp deleted file mode 100644 index d5e9754..0000000 --- a/WebCore/bindings/js/JSCustomSQLTransactionCallback.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSCustomSQLTransactionCallback.h" - -#if ENABLE(DATABASE) - -#include "Frame.h" -#include "JSCallbackData.h" -#include "JSSQLTransaction.h" -#include "ScriptExecutionContext.h" -#include <runtime/JSLock.h> -#include <wtf/MainThread.h> -#include <wtf/RefCountedLeakCounter.h> - -namespace WebCore { - -using namespace JSC; - -#ifndef NDEBUG -static WTF::RefCountedLeakCounter counter("JSCustomSQLTransactionCallback"); -#endif - -JSCustomSQLTransactionCallback::JSCustomSQLTransactionCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) -{ -#ifndef NDEBUG - counter.increment(); -#endif -} - -JSCustomSQLTransactionCallback::~JSCustomSQLTransactionCallback() -{ - callOnMainThread(JSCallbackData::deleteData, m_data); -#ifndef NDEBUG - m_data = 0; - counter.decrement(); -#endif -} - -void JSCustomSQLTransactionCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, bool& raisedException) -{ - ASSERT(m_data); - ASSERT(context); - - RefPtr<JSCustomSQLTransactionCallback> protect(this); - - JSC::JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return; - - ExecState* exec = globalObject->globalExec(); - MarkedArgumentBuffer args; - args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), transaction)); - m_data->invokeCallback(args, &raisedException); -} - -} - -#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSCustomSQLTransactionCallback.h b/WebCore/bindings/js/JSCustomSQLTransactionCallback.h deleted file mode 100644 index bf2ae68..0000000 --- a/WebCore/bindings/js/JSCustomSQLTransactionCallback.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSCustomSQLTransactionCallback_h -#define JSCustomSQLTransactionCallback_h - -#if ENABLE(DATABASE) - -#include "JSDOMGlobalObject.h" -#include "SQLTransactionCallback.h" -#include <wtf/Forward.h> - -namespace WebCore { - -class Frame; -class JSCallbackData; -class JSDOMGlobalObject; - -class JSCustomSQLTransactionCallback : public SQLTransactionCallback { -public: - static PassRefPtr<JSCustomSQLTransactionCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - { - return adoptRef(new JSCustomSQLTransactionCallback(callback, globalObject)); - } - - virtual ~JSCustomSQLTransactionCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLTransaction*, bool& raisedException); - -private: - JSCustomSQLTransactionCallback(JSC::JSObject* callback, JSDOMGlobalObject*); - - JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; -}; - -} - -#endif // ENABLE(DATABASE) - -#endif // JSCustomSQLTransactionCallback_h diff --git a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp deleted file mode 100644 index 09ff340..0000000 --- a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSCustomSQLTransactionErrorCallback.h" - -#if ENABLE(DATABASE) - -#include "Frame.h" -#include "JSCallbackData.h" -#include "JSSQLError.h" -#include "ScriptExecutionContext.h" -#include <runtime/JSLock.h> -#include <wtf/MainThread.h> - -namespace WebCore { - -using namespace JSC; - -JSCustomSQLTransactionErrorCallback::JSCustomSQLTransactionErrorCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) -{ -} - -JSCustomSQLTransactionErrorCallback::~JSCustomSQLTransactionErrorCallback() -{ - callOnMainThread(JSCallbackData::deleteData, m_data); -#ifndef NDEBUG - m_data = 0; -#endif -} - -void JSCustomSQLTransactionErrorCallback::handleEvent(ScriptExecutionContext* context, SQLError* error) -{ - ASSERT(m_data); - ASSERT(context); - - RefPtr<JSCustomSQLTransactionErrorCallback> protect(this); - - JSC::JSLock lock(SilenceAssertionsOnly); - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return; - - ExecState* exec = globalObject->globalExec(); - MarkedArgumentBuffer args; - args.append(toJS(exec, deprecatedGlobalObjectForPrototype(exec), error)); - m_data->invokeCallback(args); -} - -} - -#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h b/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h deleted file mode 100644 index bb92393..0000000 --- a/WebCore/bindings/js/JSCustomSQLTransactionErrorCallback.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSCustomSQLTransactionErrorCallback_h -#define JSCustomSQLTransactionErrorCallback_h - -#if ENABLE(DATABASE) - -#include "JSCallbackData.h" -#include "SQLTransactionErrorCallback.h" -#include <wtf/Forward.h> - -namespace WebCore { - -class JSCallbackData; -class SQLError; - -class JSCustomSQLTransactionErrorCallback : public SQLTransactionErrorCallback { -public: - static PassRefPtr<JSCustomSQLTransactionErrorCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - { - return adoptRef(new JSCustomSQLTransactionErrorCallback(callback, globalObject)); - } - - virtual ~JSCustomSQLTransactionErrorCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLError*); - -private: - JSCustomSQLTransactionErrorCallback(JSC::JSObject* callback, JSDOMGlobalObject* globalObject); - - JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; -}; - -} -#endif // ENABLE(DATABASE) - -#endif // JSCustomSQLTransactionErrorCallback_h diff --git a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp index 6198d6e..b1f82a8 100644 --- a/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp +++ b/WebCore/bindings/js/JSDOMApplicationCacheCustom.cpp @@ -85,26 +85,6 @@ JSValue JSDOMApplicationCache::remove(ExecState* exec, const ArgList& args) #endif // ENABLE(APPLICATION_CACHE_DYNAMIC_ENTRIES) -JSValue JSDOMApplicationCache::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSDOMApplicationCache::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - } // namespace WebCore #endif // ENABLE(OFFLINE_WEB_APPLICATIONS) diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index f5f2ae2..05ea9b1 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -36,8 +36,10 @@ #include "HTMLDocument.h" #include "History.h" #include "JSAudioConstructor.h" +#if ENABLE(DATABASE) #include "JSDatabase.h" #include "JSDatabaseCallback.h" +#endif #include "JSDOMWindowShell.h" #include "JSEvent.h" #include "JSEventListener.h" diff --git a/WebCore/bindings/js/JSDatabaseCallback.cpp b/WebCore/bindings/js/JSDatabaseCallback.cpp deleted file mode 100644 index 6887c86..0000000 --- a/WebCore/bindings/js/JSDatabaseCallback.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "JSDatabaseCallback.h" - -#if ENABLE(DATABASE) - -#include "Frame.h" -#include "JSDatabase.h" -#include "ScriptExecutionContext.h" -#include <runtime/JSLock.h> -#include <wtf/MainThread.h> - -namespace WebCore { - -using namespace JSC; - -JSDatabaseCallback::JSDatabaseCallback(JSObject* callback, JSDOMGlobalObject* globalObject) - : m_data(new JSCallbackData(callback, globalObject)) - , m_isolatedWorld(globalObject->world()) -{ -} - -JSDatabaseCallback::~JSDatabaseCallback() -{ - callOnMainThread(JSCallbackData::deleteData, m_data); -#ifndef NDEBUG - m_data = 0; -#endif -} - -void JSDatabaseCallback::handleEvent(ScriptExecutionContext* context, Database* database) -{ - ASSERT(m_data); - ASSERT(context); - - RefPtr<JSDatabaseCallback> protect(this); - - JSC::JSLock lock(SilenceAssertionsOnly); - - JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); - if (!globalObject) - return; - - ExecState* exec = globalObject->globalExec(); - MarkedArgumentBuffer args; - args.append(toJS(exec, database)); - - bool ignored; - m_data->invokeCallback(args, &ignored); -} - -} - -#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSDatabaseCallback.h b/WebCore/bindings/js/JSDatabaseCallback.h deleted file mode 100644 index 752a2c3..0000000 --- a/WebCore/bindings/js/JSDatabaseCallback.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef JSDatabaseCallback_h -#define JSDatabaseCallback_h - -#if ENABLE(DATABASE) - -#include "DatabaseCallback.h" -#include "JSCallbackData.h" -#include <wtf/Forward.h> - -namespace WebCore { - -class ScriptExecutionContext; - -class JSDatabaseCallback : public DatabaseCallback { -public: - static PassRefPtr<JSDatabaseCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - { - return adoptRef(new JSDatabaseCallback(callback, globalObject)); - } - - virtual ~JSDatabaseCallback(); - - virtual void handleEvent(ScriptExecutionContext*, Database*); - -private: - JSDatabaseCallback(JSC::JSObject* callback, JSDOMGlobalObject*); - - JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; -}; - -} - -#endif // ENABLE(DATABASE) - -#endif // JSDatabaseCallback_h diff --git a/WebCore/bindings/js/JSDatabaseCustom.cpp b/WebCore/bindings/js/JSDatabaseCustom.cpp index 50f1d17..ccc5c0d 100644 --- a/WebCore/bindings/js/JSDatabaseCustom.cpp +++ b/WebCore/bindings/js/JSDatabaseCustom.cpp @@ -35,8 +35,8 @@ #include "Database.h" #include "Document.h" #include "ExceptionCode.h" -#include "JSCustomSQLTransactionCallback.h" -#include "JSCustomSQLTransactionErrorCallback.h" +#include "JSSQLTransactionCallback.h" +#include "JSSQLTransactionErrorCallback.h" #include "JSCustomVoidCallback.h" #include "JSDOMWindowCustom.h" #include "PlatformString.h" @@ -58,7 +58,7 @@ JSValue JSDatabase::changeVersion(ExecState* exec, const ArgList& args) return jsUndefined(); } - RefPtr<SQLTransactionCallback> callback(JSCustomSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()))); + RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()))); RefPtr<SQLTransactionErrorCallback> errorCallback; if (!args.at(3).isNull()) { @@ -67,7 +67,7 @@ JSValue JSDatabase::changeVersion(ExecState* exec, const ArgList& args) return jsUndefined(); } - errorCallback = JSCustomSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); + errorCallback = JSSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); } RefPtr<VoidCallback> successCallback; @@ -94,16 +94,15 @@ static JSValue createTransaction(ExecState* exec, const ArgList& args, Database* return jsUndefined(); } - RefPtr<SQLTransactionCallback> callback(JSCustomSQLTransactionCallback::create(object, globalObject)); + RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, globalObject)); RefPtr<SQLTransactionErrorCallback> errorCallback; - if (args.size() > 1 && !args.at(1).isNull()) { if (!(object = args.at(1).getObject())) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - errorCallback = JSCustomSQLTransactionErrorCallback::create(object, globalObject); + errorCallback = JSSQLTransactionErrorCallback::create(object, globalObject); } RefPtr<VoidCallback> successCallback; diff --git a/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp b/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp index f86bae5..387f5f5 100644 --- a/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp +++ b/WebCore/bindings/js/JSDesktopNotificationsCustom.cpp @@ -61,27 +61,6 @@ JSValue JSNotificationCenter::requestPermission(ExecState* exec, const ArgList& return jsUndefined(); } -JSValue JSNotification::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSNotification::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - - } // namespace #endif // ENABLE(NOTIFICATIONS) diff --git a/WebCore/bindings/js/JSEventListener.cpp b/WebCore/bindings/js/JSEventListener.cpp index 3853cfc..c64aa29 100644 --- a/WebCore/bindings/js/JSEventListener.cpp +++ b/WebCore/bindings/js/JSEventListener.cpp @@ -34,10 +34,11 @@ namespace WebCore { JSEventListener::JSEventListener(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld) : EventListener(JSEventListenerType) , m_jsFunction(function) - , m_wrapper(wrapper) , m_isAttribute(isAttribute) , m_isolatedWorld(isolatedWorld) { + if (wrapper) + m_wrapper = wrapper; } JSEventListener::~JSEventListener() @@ -59,7 +60,7 @@ void JSEventListener::markJSFunction(MarkStack& markStack) void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event) { ASSERT(scriptExecutionContext); - if (!scriptExecutionContext) + if (!scriptExecutionContext || scriptExecutionContext->isJSExecutionTerminated()) return; JSLock lock(SilenceAssertionsOnly); diff --git a/WebCore/bindings/js/JSEventSourceCustom.cpp b/WebCore/bindings/js/JSEventSourceCustom.cpp deleted file mode 100644 index 86db431..0000000 --- a/WebCore/bindings/js/JSEventSourceCustom.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2009 Ericsson AB - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Ericsson nor the names of its contributors - * may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(EVENTSOURCE) - -#include "JSEventSource.h" - -#include "EventSource.h" -#include "JSDOMGlobalObject.h" -#include "JSEventListener.h" - -using namespace JSC; - -namespace WebCore { - -JSValue JSEventSource::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSEventSource::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -} // namespace WebCore - -#endif // ENABLE(EVENTSOURCE) diff --git a/WebCore/bindings/js/JSHTMLFormElementCustom.cpp b/WebCore/bindings/js/JSHTMLFormElementCustom.cpp index 2e7522c..4dd0b81 100644 --- a/WebCore/bindings/js/JSHTMLFormElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLFormElementCustom.cpp @@ -61,13 +61,4 @@ JSValue JSHTMLFormElement::nameGetter(ExecState* exec, JSValue slotBase, const I return toJS(exec, jsForm->globalObject(), StaticNodeList::adopt(namedItems).get()); } -JSValue JSHTMLFormElement::submit(ExecState* exec, const ArgList&) -{ - Frame* activeFrame = asJSDOMWindow(exec->dynamicGlobalObject())->impl()->frame(); - if (!activeFrame) - return jsUndefined(); - static_cast<HTMLFormElement*>(impl())->submit(activeFrame); - return jsUndefined(); -} - } diff --git a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp index 8bfb8a3..1fedd7e 100644 --- a/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp +++ b/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp @@ -129,12 +129,6 @@ JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec, const ArgList&) JSLock lock(SilenceAssertionsOnly); return toJS(exec, callFrame); } - -JSValue JSInjectedScriptHost::isActivation(ExecState*, const ArgList& args) -{ - JSObject* object = args.at(0).getObject(); - return jsBoolean(object && object->isActivationObject()); -} #endif JSValue JSInjectedScriptHost::nodeForId(ExecState* exec, const ArgList& args) diff --git a/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp b/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp index 080f730..f45abf6 100644 --- a/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp +++ b/WebCore/bindings/js/JSJavaScriptCallFrameCustom.cpp @@ -85,10 +85,41 @@ JSValue JSJavaScriptCallFrame::scopeChain(ExecState* exec) const return constructArray(exec, list); } -JSValue JSJavaScriptCallFrame::scopeType(ExecState*, const ArgList&) +JSValue JSJavaScriptCallFrame::scopeType(ExecState* exec, const ArgList& args) { - // FIXME(37663): implement this method the way it's done in the InjectedScipt.js - return jsNull(); + if (!impl()->scopeChain()) + return jsUndefined(); + + if (!args.at(0).isInt32()) + return jsUndefined(); + int index = args.at(0).asInt32(); + + const ScopeChainNode* scopeChain = impl()->scopeChain(); + ScopeChainIterator end = scopeChain->end(); + + bool foundLocalScope = false; + for (ScopeChainIterator iter = scopeChain->begin(); iter != end; ++iter) { + JSObject* scope = *iter; + if (scope->isActivationObject()) { + if (!foundLocalScope) { + // First activation object is local scope, each successive activation object is closure. + if (!index) + return jsJavaScriptCallFrameLOCAL_SCOPE(exec, JSValue(), Identifier()); + foundLocalScope = true; + } else if (!index) + return jsJavaScriptCallFrameCLOSURE_SCOPE(exec, JSValue(), Identifier()); + } + + if (!index) { + // Last in the chain is global scope. + if (++iter == end) + return jsJavaScriptCallFrameGLOBAL_SCOPE(exec, JSValue(), Identifier()); + return jsJavaScriptCallFrameWITH_SCOPE(exec, JSValue(), Identifier()); + } + + --index; + } + return jsUndefined(); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSMessagePortCustom.cpp b/WebCore/bindings/js/JSMessagePortCustom.cpp index f7c0160..4c1491d 100644 --- a/WebCore/bindings/js/JSMessagePortCustom.cpp +++ b/WebCore/bindings/js/JSMessagePortCustom.cpp @@ -52,26 +52,6 @@ void JSMessagePort::markChildren(MarkStack& markStack) m_impl->markJSEventListeners(markStack); } -JSValue JSMessagePort::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSMessagePort::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - JSC::JSValue JSMessagePort::postMessage(JSC::ExecState* exec, const JSC::ArgList& args) { return handlePostMessage(exec, args, impl()); diff --git a/WebCore/bindings/js/JSNodeCustom.cpp b/WebCore/bindings/js/JSNodeCustom.cpp index 3a07b29..6d61037 100644 --- a/WebCore/bindings/js/JSNodeCustom.cpp +++ b/WebCore/bindings/js/JSNodeCustom.cpp @@ -169,26 +169,6 @@ JSValue JSNode::appendChild(ExecState* exec, const ArgList& args) return jsNull(); } -JSValue JSNode::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSNode::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - void JSNode::pushEventHandlerScope(ExecState*, ScopeChain&) const { } @@ -199,6 +179,7 @@ void JSNode::markChildren(MarkStack& markStack) Node* node = m_impl.get(); node->markJSEventListeners(markStack); + node->markCachedNodeLists(markStack, *Heap::heap(this)->globalData()); // Nodes in the document are kept alive by JSDocument::mark, so, if we're in // the document, we need to mark the document, but we don't need to explicitly diff --git a/WebCore/bindings/js/JSNodeFilterCustom.cpp b/WebCore/bindings/js/JSNodeFilterCustom.cpp index 2a99a93..bb90c4f 100644 --- a/WebCore/bindings/js/JSNodeFilterCustom.cpp +++ b/WebCore/bindings/js/JSNodeFilterCustom.cpp @@ -41,11 +41,6 @@ void JSNodeFilter::markChildren(MarkStack& markStack) impl()->markAggregate(markStack); } -JSValue JSNodeFilter::acceptNode(ExecState* exec, const ArgList& args) -{ - return jsNumber(exec, impl()->acceptNode(exec, toNode(args.at(0)))); -} - PassRefPtr<NodeFilter> toNodeFilter(JSValue value) { if (value.inherits(&JSNodeFilter::s_info)) diff --git a/WebCore/bindings/js/JSNodeIteratorCustom.cpp b/WebCore/bindings/js/JSNodeIteratorCustom.cpp index 6a09abf..7c858e5 100644 --- a/WebCore/bindings/js/JSNodeIteratorCustom.cpp +++ b/WebCore/bindings/js/JSNodeIteratorCustom.cpp @@ -37,34 +37,4 @@ void JSNodeIterator::markChildren(MarkStack& markStack) filter->markAggregate(markStack); } -JSValue JSNodeIterator::nextNode(ExecState* exec, const ArgList&) -{ - ExceptionCode ec = 0; - RefPtr<Node> node = impl()->nextNode(exec, ec); - if (ec) { - setDOMException(exec, ec); - return jsUndefined(); - } - - if (exec->hadException()) - return jsUndefined(); - - return toJS(exec, node.get()); -} - -JSValue JSNodeIterator::previousNode(ExecState* exec, const ArgList&) -{ - ExceptionCode ec = 0; - RefPtr<Node> node = impl()->previousNode(exec, ec); - if (ec) { - setDOMException(exec, ec); - return jsUndefined(); - } - - if (exec->hadException()) - return jsUndefined(); - - return toJS(exec, node.get()); -} - } diff --git a/WebCore/bindings/js/JSPopStateEventCustom.cpp b/WebCore/bindings/js/JSPopStateEventCustom.cpp index ce430ab..14fc9d9 100644 --- a/WebCore/bindings/js/JSPopStateEventCustom.cpp +++ b/WebCore/bindings/js/JSPopStateEventCustom.cpp @@ -33,16 +33,6 @@ using namespace JSC; namespace WebCore { -JSValue JSPopStateEvent::initPopStateEvent(ExecState* exec, const ArgList& args) -{ - const UString& typeArg = args.at(0).toString(exec); - bool canBubbleArg = args.at(1).toBoolean(exec); - bool cancelableArg = args.at(2).toBoolean(exec); - RefPtr<SerializedScriptValue> stateObjectArg = SerializedScriptValue::create(exec, args.at(3)); - - PopStateEvent* event = static_cast<PopStateEvent*>(impl()); - event->initPopStateEvent(ustringToAtomicString(typeArg), canBubbleArg, cancelableArg, stateObjectArg.release()); - return jsUndefined(); -} +// FIXME: Remove this file. } // namespace WebCore diff --git a/WebCore/bindings/js/JSSQLTransactionCustom.cpp b/WebCore/bindings/js/JSSQLTransactionCustom.cpp index 81e6c63..802a384 100644 --- a/WebCore/bindings/js/JSSQLTransactionCustom.cpp +++ b/WebCore/bindings/js/JSSQLTransactionCustom.cpp @@ -33,8 +33,8 @@ #include "DOMWindow.h" #include "ExceptionCode.h" -#include "JSCustomSQLStatementCallback.h" -#include "JSCustomSQLStatementErrorCallback.h" +#include "JSSQLStatementCallback.h" +#include "JSSQLStatementErrorCallback.h" #include "JSDOMWindowCustom.h" #include "SQLTransaction.h" @@ -95,7 +95,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) return jsUndefined(); } - callback = JSCustomSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); + callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); } RefPtr<SQLStatementErrorCallback> errorCallback; @@ -106,7 +106,7 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) return jsUndefined(); } - errorCallback = JSCustomSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); + errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); } ExceptionCode ec = 0; diff --git a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp index fdcab06..ccf5ccd 100644 --- a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp +++ b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp @@ -46,26 +46,6 @@ void JSSVGElementInstance::markChildren(MarkStack& markStack) markDOMNodeWrapper(markStack, impl()->correspondingElement()->document(), impl()->correspondingElement()); } -JSValue JSSVGElementInstance::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSSVGElementInstance::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - void JSSVGElementInstance::pushEventHandlerScope(ExecState*, ScopeChain&) const { } diff --git a/WebCore/bindings/js/JSTreeWalkerCustom.cpp b/WebCore/bindings/js/JSTreeWalkerCustom.cpp index f879cf4..0c1947f 100644 --- a/WebCore/bindings/js/JSTreeWalkerCustom.cpp +++ b/WebCore/bindings/js/JSTreeWalkerCustom.cpp @@ -36,61 +36,5 @@ void JSTreeWalker::markChildren(MarkStack& markStack) if (NodeFilter* filter = m_impl->filter()) filter->markAggregate(markStack); } - -JSValue JSTreeWalker::parentNode(ExecState* exec, const ArgList&) -{ - Node* node = impl()->parentNode(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::firstChild(ExecState* exec, const ArgList&) -{ - Node* node = impl()->firstChild(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::lastChild(ExecState* exec, const ArgList&) -{ - Node* node = impl()->lastChild(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::nextSibling(ExecState* exec, const ArgList&) -{ - Node* node = impl()->nextSibling(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::previousSibling(ExecState* exec, const ArgList&) -{ - Node* node = impl()->previousSibling(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::previousNode(ExecState* exec, const ArgList&) -{ - Node* node = impl()->previousNode(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} - -JSValue JSTreeWalker::nextNode(ExecState* exec, const ArgList&) -{ - Node* node = impl()->nextNode(exec); - if (exec->hadException()) - return jsUndefined(); - return toJS(exec, node); -} } diff --git a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp b/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp index 8671908..5f1f643 100644 --- a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp +++ b/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp @@ -30,6 +30,7 @@ #include "JSWebGLArrayBufferConstructor.h" #include "Document.h" +#include "ExceptionCode.h" #include "JSWebGLArrayBuffer.h" namespace WebCore { diff --git a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index e336027..41000fd 100644 --- a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -32,10 +32,8 @@ #include "ExceptionCode.h" #include "HTMLCanvasElement.h" #include "HTMLImageElement.h" -#include "HTMLVideoElement.h" #include "JSHTMLCanvasElement.h" #include "JSHTMLImageElement.h" -#include "JSHTMLVideoElement.h" #include "JSImageData.h" #include "JSWebGLBuffer.h" #include "JSWebGLFloatArray.h" @@ -60,6 +58,11 @@ #include <wtf/FastMalloc.h> #include <wtf/OwnFastMallocPtr.h> +#if ENABLE(VIDEO) +#include "HTMLVideoElement.h" +#include "JSHTMLVideoElement.h" +#endif + using namespace JSC; namespace WebCore { @@ -352,9 +355,11 @@ JSValue JSWebGLRenderingContext::texImage2D(ExecState* exec, const ArgList& args } else if (o->inherits(&JSHTMLCanvasElement::s_info)) { HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLCanvasElement*>(o)->impl()); context->texImage2D(target, level, element, flipY, premultiplyAlpha, ec); +#if ENABLE(VIDEO) } else if (o->inherits(&JSHTMLVideoElement::s_info)) { HTMLVideoElement* element = static_cast<HTMLVideoElement*>(static_cast<JSHTMLVideoElement*>(o)->impl()); context->texImage2D(target, level, element, flipY, premultiplyAlpha, ec); +#endif } else ec = TYPE_MISMATCH_ERR; } else { @@ -461,9 +466,11 @@ JSValue JSWebGLRenderingContext::texSubImage2D(ExecState* exec, const ArgList& a } else if (o->inherits(&JSHTMLCanvasElement::s_info)) { HTMLCanvasElement* element = static_cast<HTMLCanvasElement*>(static_cast<JSHTMLCanvasElement*>(o)->impl()); context->texSubImage2D(target, level, xoff, yoff, element, flipY, premultiplyAlpha, ec); +#if ENABLE(VIDEO) } else if (o->inherits(&JSHTMLVideoElement::s_info)) { HTMLVideoElement* element = static_cast<HTMLVideoElement*>(static_cast<JSHTMLVideoElement*>(o)->impl()); context->texSubImage2D(target, level, xoff, yoff, element, flipY, premultiplyAlpha, ec); +#endif } else ec = TYPE_MISMATCH_ERR; } else { diff --git a/WebCore/bindings/js/JSWebSocketCustom.cpp b/WebCore/bindings/js/JSWebSocketCustom.cpp index 18f4183..149ac5d 100644 --- a/WebCore/bindings/js/JSWebSocketCustom.cpp +++ b/WebCore/bindings/js/JSWebSocketCustom.cpp @@ -59,26 +59,6 @@ JSValue JSWebSocket::send(ExecState* exec, const ArgList& args) return ret; } -JSValue JSWebSocket::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSWebSocket::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - } // namespace WebCore #endif diff --git a/WebCore/bindings/js/JSWorkerContextBase.cpp b/WebCore/bindings/js/JSWorkerContextBase.cpp index 2491f4d..effe488 100644 --- a/WebCore/bindings/js/JSWorkerContextBase.cpp +++ b/WebCore/bindings/js/JSWorkerContextBase.cpp @@ -71,7 +71,9 @@ JSValue toJS(ExecState*, WorkerContext* workerContext) WorkerScriptController* script = workerContext->script(); if (!script) return jsNull(); - return script->workerContextWrapper(); + JSWorkerContext* contextWrapper = script->workerContextWrapper(); + ASSERT(contextWrapper); + return contextWrapper; } JSDedicatedWorkerContext* toJSDedicatedWorkerContext(JSValue value) diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp index 0a9489b..a70c1b3 100644 --- a/WebCore/bindings/js/JSWorkerContextCustom.cpp +++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -116,26 +116,6 @@ JSValue JSWorkerContext::importScripts(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue JSWorkerContext::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSWorkerContext::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - JSValue JSWorkerContext::setTimeout(ExecState* exec, const ArgList& args) { OwnPtr<ScheduledAction> action = ScheduledAction::create(exec, args, currentWorld(exec)); diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index da83801..fc72154 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -153,26 +153,6 @@ JSValue JSXMLHttpRequest::overrideMimeType(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue JSXMLHttpRequest::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSXMLHttpRequest::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - JSValue JSXMLHttpRequest::responseText(ExecState* exec) const { return jsOwnedStringOrNull(exec, impl()->responseText()); diff --git a/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp index 42d4eb9..091c380 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp @@ -51,24 +51,4 @@ void JSXMLHttpRequestUpload::markChildren(MarkStack& markStack) m_impl->markJSEventListeners(markStack); } -JSValue JSXMLHttpRequestUpload::addEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - -JSValue JSXMLHttpRequestUpload::removeEventListener(ExecState* exec, const ArgList& args) -{ - JSValue listener = args.at(1); - if (!listener.isObject()) - return jsUndefined(); - - impl()->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), this, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); - return jsUndefined(); -} - } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptController.cpp b/WebCore/bindings/js/ScriptController.cpp index b3695b4..508b2f8 100644 --- a/WebCore/bindings/js/ScriptController.cpp +++ b/WebCore/bindings/js/ScriptController.cpp @@ -36,6 +36,7 @@ #include "ScriptValue.h" #include "Settings.h" #include "StorageNamespace.h" +#include "UserGestureIndicator.h" #include "WebCoreJSClientData.h" #include "XSSAuditor.h" #include "npruntime_impl.h" @@ -43,6 +44,7 @@ #include <debugger/Debugger.h> #include <runtime/InitializeThreading.h> #include <runtime/JSLock.h> +#include <wtf/Threading.h> using namespace JSC; using namespace std; @@ -52,6 +54,7 @@ namespace WebCore { void ScriptController::initializeThreading() { JSC::initializeThreading(); + WTF::initializeMainThread(); } ScriptController::ScriptController(Frame* frame) @@ -70,7 +73,7 @@ ScriptController::ScriptController(Frame* frame) #endif , m_XSSAuditor(new XSSAuditor(frame)) { -#if PLATFORM(MAC) && ENABLE(MAC_JAVA_BRIDGE) +#if PLATFORM(MAC) && ENABLE(JAVA_BRIDGE) static bool initializedJavaJSBindings; if (!initializedJavaJSBindings) { initializedJavaJSBindings = true; @@ -226,19 +229,16 @@ JSDOMWindowShell* ScriptController::initScript(DOMWrapperWorld* world) bool ScriptController::processingUserGesture(DOMWrapperWorld* world) const { - return m_allowPopupsFromPlugin || processingUserGestureEvent(world) || isJavaScriptAnchorNavigation(); -} + if (m_allowPopupsFromPlugin || isJavaScriptAnchorNavigation()) + return true; -bool ScriptController::processingUserGestureEvent(DOMWrapperWorld* world) const -{ - JSDOMWindowShell* shell = existingWindowShell(world); - if (!shell) - return false; + // If a DOM event is being processed, check that it was initiated by the user + // and that it is in the whitelist of event types allowed to generate pop-ups. + if (JSDOMWindowShell* shell = existingWindowShell(world)) + if (Event* event = shell->window()->currentEvent()) + return event->fromUserGesture(); - if (Event* event = shell->window()->currentEvent()) - return event->fromUserGesture(); - - return false; + return UserGestureIndicator::processingUserGesture(); } // FIXME: This seems like an insufficient check to verify a click on a javascript: anchor. diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index d096c2e..468ac5c 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -152,7 +152,7 @@ public: PassRefPtr<JSC::Bindings::RootObject> createRootObject(void* nativeHandle); #if PLATFORM(MAC) -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) static void initJavaJSBindings(); #endif WebScriptObject* windowScriptObject(); @@ -172,7 +172,6 @@ private: void disconnectPlatformScriptObjects(); - bool processingUserGestureEvent(DOMWrapperWorld*) const; bool isJavaScriptAnchorNavigation() const; ShellMap m_windowShells; diff --git a/WebCore/bindings/js/ScriptControllerEfl.cpp b/WebCore/bindings/js/ScriptControllerEfl.cpp new file mode 100644 index 0000000..950c11e --- /dev/null +++ b/WebCore/bindings/js/ScriptControllerEfl.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. + * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com + * Copyright (C) 2007 Holger Hans Peter Freyther + * Copyright (C) 2008 Collabora Ltd. All rights reserved. + * Copyright (C) 2008 Eric Seidel <eric@webkit.org> + * Copyright (C) 2009,2010 ProFUSION embedded systems + * Copyright (C) 2009,2010 Samsung Electronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "ScriptController.h" + +#include "PluginView.h" + +namespace WebCore { + +PassRefPtr<JSC::Bindings::Instance> ScriptController::createScriptInstanceForWidget(Widget* widget) +{ + return 0; + +#if 0 // FIXME: disabled until we have Plugin system done. + if (!widget->isPluginView()) + return 0; + + return static_cast<PluginView*>(widget)->bindingInstance(); +#endif +} + +} diff --git a/WebCore/bindings/js/ScriptControllerMac.mm b/WebCore/bindings/js/ScriptControllerMac.mm index a895489..7c29bfc 100644 --- a/WebCore/bindings/js/ScriptControllerMac.mm +++ b/WebCore/bindings/js/ScriptControllerMac.mm @@ -49,7 +49,7 @@ #import "npruntime_impl.h" #endif -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) #import "JavaInstanceJSC.h" #endif @@ -95,7 +95,7 @@ PassScriptInstance ScriptController::createScriptInstanceForWidget(Widget* widge #endif } -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) jobject applet = m_frame->loader()->client()->javaApplet(widgetView); if (!applet) return 0; @@ -136,7 +136,7 @@ void ScriptController::disconnectPlatformScriptObjects() } } -#if ENABLE(MAC_JAVA_BRIDGE) +#if ENABLE(JAVA_BRIDGE) static pthread_t mainThread; diff --git a/WebCore/bindings/js/ScriptEventListener.cpp b/WebCore/bindings/js/ScriptEventListener.cpp index 01b9060..467f16b 100644 --- a/WebCore/bindings/js/ScriptEventListener.cpp +++ b/WebCore/bindings/js/ScriptEventListener.cpp @@ -105,7 +105,7 @@ PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame* frame, Attri return JSLazyEventListener::create(attr->localName().string(), eventParameterName(frame->document()->isSVGDocument()), attr->value(), 0, sourceURL, lineNumber, wrapper, mainThreadNormalWorld()); } -String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* eventListener) +String eventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* eventListener) { const JSEventListener* jsListener = JSEventListener::cast(eventListener); if (!jsListener) @@ -116,4 +116,10 @@ String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* return ustringToString(jsFunction->toString(scriptState)); } +bool eventListenerHandlerLocation(ScriptExecutionContext*, ScriptState*, EventListener*, String&, int&) +{ + // FIXME: Add support for getting function location. + return false; +} + } // namespace WebCore diff --git a/WebCore/bindings/js/ScriptEventListener.h b/WebCore/bindings/js/ScriptEventListener.h index 3396541..f1f203c 100644 --- a/WebCore/bindings/js/ScriptEventListener.h +++ b/WebCore/bindings/js/ScriptEventListener.h @@ -45,8 +45,8 @@ namespace WebCore { PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node*, Attribute*); PassRefPtr<JSLazyEventListener> createAttributeEventListener(Frame*, Attribute*); - String getEventListenerHandlerBody(ScriptExecutionContext*, ScriptState*, EventListener*); - + String eventListenerHandlerBody(ScriptExecutionContext*, ScriptState*, EventListener*); + bool eventListenerHandlerLocation(ScriptExecutionContext*, ScriptState*, EventListener*, String& sourceName, int& lineNumber); } // namespace WebCore #endif // ScriptEventListener_h diff --git a/WebCore/bindings/js/ScriptWrappable.h b/WebCore/bindings/js/ScriptWrappable.h index 5e99c1c..c57796c 100644 --- a/WebCore/bindings/js/ScriptWrappable.h +++ b/WebCore/bindings/js/ScriptWrappable.h @@ -38,8 +38,6 @@ namespace WebCore { class ScriptWrappable { public: - ScriptWrappable() : m_wrapper(0) { } - DOMObject* wrapper() const { return m_wrapper.get(); @@ -47,7 +45,6 @@ public: void setWrapper(DOMObject* wrapper) { - ASSERT(wrapper); m_wrapper = wrapper; } diff --git a/WebCore/bindings/js/WorkerScriptController.h b/WebCore/bindings/js/WorkerScriptController.h index 38c3c30..60c3b04 100644 --- a/WebCore/bindings/js/WorkerScriptController.h +++ b/WebCore/bindings/js/WorkerScriptController.h @@ -52,9 +52,6 @@ namespace WebCore { JSWorkerContext* workerContextWrapper() { - if (m_executionForbidden) - return 0; - initScriptIfNeeded(); return m_workerContextWrapper; } @@ -66,6 +63,7 @@ namespace WebCore { enum ForbidExecutionOption { TerminateRunningScript, LetRunningScriptFinish }; void forbidExecution(ForbidExecutionOption); + bool isExecutionForbidden() const { return m_executionForbidden; } JSC::JSGlobalData* globalData() { return m_globalData.get(); } diff --git a/WebCore/bindings/objc/WebScriptObject.mm b/WebCore/bindings/objc/WebScriptObject.mm index 618459a..1cec41c 100644 --- a/WebCore/bindings/objc/WebScriptObject.mm +++ b/WebCore/bindings/objc/WebScriptObject.mm @@ -49,6 +49,7 @@ #import <runtime/JSLock.h> #import <runtime/Completion.h> #import <runtime/Completion.h> +#import <wtf/Threading.h> #ifdef BUILDING_ON_TIGER typedef unsigned NSUInteger; @@ -109,6 +110,7 @@ static void addExceptionToConsole(ExecState* exec) + (void)initialize { JSC::initializeThreading(); + WTF::initializeMainThreadToProcessMainThread(); #ifndef BUILDING_ON_TIGER WebCoreObjCFinalizeOnMainThread(self); #endif diff --git a/WebCore/bindings/scripts/CodeGeneratorGObject.pm b/WebCore/bindings/scripts/CodeGeneratorGObject.pm index 2a38eff..1d03f08 100644 --- a/WebCore/bindings/scripts/CodeGeneratorGObject.pm +++ b/WebCore/bindings/scripts/CodeGeneratorGObject.pm @@ -26,6 +26,10 @@ package CodeGeneratorGObject; my %implIncludes = (); my %hdrIncludes = (); +my @txtInstallProps = (); +my @txtSetProps = (); +my @txtGetProps = (); + my $className = ""; # Default constructor @@ -95,6 +99,16 @@ sub decamelize $s; } +sub FixUpDecamelizedName { + my $classname = shift; + + # FIXME: try to merge this somehow with the fixes in ClassNameToGobjectType + $classname =~ s/x_path/xpath/; + $classname =~ s/web_kit/webkit/; + + return $classname; +} + sub ClassNameToGObjectType { my $className = shift; my $CLASS_NAME = uc(decamelize($className)); @@ -102,6 +116,11 @@ sub ClassNameToGObjectType { # WebKitDOMCSS right, so we have to fix it manually (and there # might be more like this in the future) $CLASS_NAME =~ s/DOMCSS/DOM_CSS/; + $CLASS_NAME =~ s/DOMHTML/DOM_HTML/; + $CLASS_NAME =~ s/DOMDOM/DOM_DOM/; + $CLASS_NAME =~ s/DOMCDATA/DOM_CDATA/; + $CLASS_NAME =~ s/DOMX_PATH/DOM_XPATH/; + $CLASS_NAME =~ s/DOM_WEB_KIT/DOM_WEBKIT/; return $CLASS_NAME; } @@ -128,7 +147,8 @@ sub SkipAttribute { my $attribute = shift; if ($attribute->signature->extendedAttributes->{"CustomGetter"} || - $attribute->signature->extendedAttributes->{"CustomSetter"}) { + $attribute->signature->extendedAttributes->{"CustomSetter"} || + $attribute->signature->extendedAttributes->{"Replaceable"}) { return 1; } @@ -141,6 +161,55 @@ sub SkipAttribute { return 1; } + # This is for DOMWindow.idl location attribute + if ($attribute->signature->name eq "location") { + return 1; + } + + # This is for HTMLInput.idl valueAsDate + if ($attribute->signature->name eq "valueAsDate") { + return 1; + } + + # This is for DOMWindow.idl Crypto attribute + if ($attribute->signature->type eq "Crypto") { + return 1; + } + + return 0; +} + +sub SkipFunction { + my $function = shift; + my $decamelize = shift; + my $prefix = shift; + + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($function->signature->name); + my $isCustomFunction = $function->signature->extendedAttributes->{"Custom"} || + $function->signature->extendedAttributes->{"CustomArgumentHandling"}; + + if ($isCustomFunction && + $functionName ne "webkit_dom_node_replace_child" && + $functionName ne "webkit_dom_node_insert_before" && + $functionName ne "webkit_dom_node_replace_child" && + $functionName ne "webkit_dom_node_append_child" && + $functionName ne "webkit_dom_html_collection_item" && + $functionName ne "webkit_dom_html_collection_named_item") { + return 1; + } + + if ($function->signature->type eq "Event") { + return 1; + } + + if ($function->signature->name eq "getSVGDocument") { + return 1; + } + + if ($function->signature->name eq "getCSSCanvasContext") { + return 1; + } + return 0; } @@ -154,6 +223,7 @@ sub GetGValueTypeName { "boolean", "boolean", "char", "char", "long", "long", + "long long", "int64", "short", "int", "uchar", "uchar", "unsigned", "uint", @@ -172,11 +242,13 @@ sub GetGlibTypeName { my $name = GetClassName($type); my %types = ("DOMString", "gchar* ", + "CompareHow", "gushort", "float", "gfloat", "double", "gdouble", "boolean", "gboolean", "char", "gchar", "long", "glong", + "long long", "gint64", "short", "gshort", "uchar", "guchar", "unsigned", "guint", @@ -193,30 +265,192 @@ sub GetGlibTypeName { sub IsGDOMClassType { my $type = shift; - return 0 if $type eq "DOMString"; - return 0 if $type eq "float"; - return 0 if $type eq "double"; - return 0 if $type eq "boolean"; - return 0 if $type eq "char"; - return 0 if $type eq "long"; - return 0 if $type eq "short"; - return 0 if $type eq "uchar"; - return 0 if $type eq "unsigned"; - return 0 if $type eq "int"; - return 0 if $type eq "unsigned int"; - return 0 if $type eq "unsigned long"; - return 0 if $type eq "unsigned long long"; - return 0 if $type eq "unsigned short"; - return 0 if $type eq "void"; - + return 0 if $codeGenerator->IsNonPointerType($type) || $codeGenerator->IsStringType($type); return 1; } +sub GetReadableProperties { + my $properties = shift; + + my @result = (); + + foreach my $property (@{$properties}) { + if (!SkipAttribute($property)) { + push(@result, $property); + } + } + + return @result; +} + +sub GetWriteableProperties { + my $properties = shift; + my @result = (); + + foreach my $property (@{$properties}) { + my $writeable = $property->type !~ /^readonly/; + my $gtype = GetGValueTypeName($property->signature->type); + my $hasGtypeSignature = ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" || + $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || + $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" || + $gtype eq "char" || $gtype eq "string"); + if ($writeable && $hasGtypeSignature) { + push(@result, $property); + } + } + + return @result; +} + +sub GenerateProperty { + my $attribute = shift; + my $interfaceName = shift; + my @writeableProperties = @{shift @_}; + + my $camelPropName = $attribute->signature->name; + my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); + my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); + + my $propName = decamelize($camelPropName); + my $propNameCaps = uc($propName); + $propName =~ s/_/-/g; + my ${propEnum} = "PROP_${propNameCaps}"; + push(@cBodyPriv, " ${propEnum},\n"); + + my $propType = $attribute->signature->type; + my ${propGType} = decamelize($propType); + if ($propGType eq "event_target") { + $propGType = "event_target_node"; + } + my ${ucPropGType} = uc($propGType); + + my $gtype = GetGValueTypeName($propType); + my $gparamflag = "WEBKIT_PARAM_READABLE"; + my $writeable = $attribute->type !~ /^readonly/; + my $const = "read-only "; + my $custom = $attribute->signature->extendedAttributes->{"Custom"}; + if ($writeable && $custom) { + $const = "read-only (due to custom functions needed in webkitdom)"; + return; + } + if ($writeable && !$custom) { + $gparamflag = "WEBKIT_PARAM_READWRITE"; + $const = "read-write "; + } + + my $type = GetGlibTypeName($propType); + $nick = decamelize("${interfaceName}_${propName}"); + $long = "${const} ${type} ${interfaceName}.${propName}"; + + my $convertFunction = ""; + if ($gtype eq "string") { + $convertFunction = "WebCore::String::fromUTF8"; + } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { + $convertFunction = "WebCore::String::number"; + } + + my $setterContentHead; + my $getterContentHead; + my $reflect = $attribute->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $attribute->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $camelPropName : ($reflect || $reflectURL); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $setterContentHead = "coreSelf->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${convertFunction}(g_value_get_$gtype(value))"; + $getterContentHead = "coreSelf->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr"; + } else { + $setterContentHead = "coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))"; + $getterContentHead = "coreSelf->${getPropNameFunction}("; + } + + if (grep {$_ eq $attribute} @writeableProperties) { + push(@txtSetProps, " case ${propEnum}:\n {\n"); + push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; + push(@txtSetProps, " ${setterContentHead}"); + push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; + push(@txtSetProps, ");\n"); + push(@txtSetProps, " break;\n }\n"); + } + + push(@txtGetProps, " case ${propEnum}:\n {\n"); + + my $exception = ""; + if (@{$attribute->getterExceptions}) { + $exception = "ec"; + push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n"); + } + + my $postConvertFunction = ""; + my $done = 0; + if ($gtype eq "string") { + push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(${getterContentHead}${exception})));\n"); + $done = 1; + } elsif ($gtype eq "object") { + $txtGetProp = << "EOF"; + RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception}); + g_value_set_object(value, WebKit::kit(ptr.get())); +EOF + push(@txtGetProps, $txtGetProp); + $done = 1; + } + + if($attribute->signature->extendedAttributes->{"ConvertFromString"}) { + # TODO: Add other conversion functions for different types. Current + # IDLs only list longs. + if($gtype eq "long") { + $convertFunction = ""; + $postConvertFunction = ".toInt()"; + } else { + die "Can't convert to type ${gtype}."; + } + } + + # FIXME: get rid of this glitch? + my $_gtype = $gtype; + if ($gtype eq "ushort") { + $_gtype = "uint"; + } + + if (!$done) { + push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getPropNameFunction}(${exception})${postConvertFunction});\n"); + } + + push(@txtGetProps, " break;\n }\n"); + + my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", + "boolean", "FALSE, /* default */", + "float", "-G_MAXFLOAT, /* min */\nG_MAXFLOAT, /* max */\n0.0, /* default */", + "double", "-G_MAXDOUBLE, /* min */\nG_MAXDOUBLE, /* max */\n0.0, /* default */", + "uint64", "0, /* min */\nG_MAXUINT64, /* min */\n0, /* default */", + "long", "G_MINLONG, /* min */\nG_MAXLONG, /* max */\n0, /* default */", + "int64", "G_MININT64, /* min */\nG_MAXINT64, /* max */\n0, /* default */", + "ulong", "0, /* min */\nG_MAXULONG, /* max */\n0, /* default */", + "uint", "0, /* min */\nG_MAXUINT, /* max */\n0, /* default */", + "ushort", "0, /* min */\nG_MAXUINT16, /* max */\n0, /* default */", + "uchar", "G_MININT8, /* min */\nG_MAXINT8, /* max */\n0, /* default */", + "char", "0, /* min */\nG_MAXUINT8, /* max */\n0, /* default */", + "string", "\"\", /* default */", + "object", "WEBKIT_TYPE_DOM_${ucPropGType}, /* gobject type */"); + + my $txtInstallProp = << "EOF"; + g_object_class_install_property(gobjectClass, + ${propEnum}, + g_param_spec_${_gtype}("${propName}", /* name */ + "$nick", /* short description */ + "$long", /* longer - could do with some extra doc stuff here */ + $param_spec_options{$gtype} + ${gparamflag})); +EOF + push(@txtInstallProps, $txtInstallProp); +} + sub GenerateProperties { my ($object, $interfaceName, $dataNode) = @_; my $clsCaps = substr(ClassNameToGObjectType($className), 12); - my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName)); + my $lowerCaseIfaceName = "webkit_dom_" . (FixUpDecamelizedName(decamelize($interfaceName))); # Properties my $implContent = ""; @@ -228,169 +462,51 @@ enum { EOF push(@cBodyPriv, $implContent); - my @txtInstallProps = (); - my @txtSetProps = (); - my @txtGetProps = (); + my @readableProperties = GetReadableProperties($dataNode->attributes); my $privFunction = GetCoreObject($interfaceName, "coreSelf", "self"); my $txtGetProp = << "EOF"; static void ${lowerCaseIfaceName}_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { +EOF + push(@txtGetProps, $txtGetProp); + if (scalar @readableProperties > 0) { + $txtGetProp = << "EOF"; ${className}* self = WEBKIT_DOM_${clsCaps}(object); $privFunction +EOF + push(@txtGetProps, $txtGetProp); + } + $txtGetProp = << "EOF"; switch (prop_id) { EOF push(@txtGetProps, $txtGetProp); + my @writeableProperties = GetWriteableProperties(\@readableProperties); + my $txtSetProps = << "EOF"; static void ${lowerCaseIfaceName}_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) { +EOF + push(@txtSetProps, $txtSetProps); + + if (scalar @writeableProperties > 0) { + $txtSetProps = << "EOF"; ${className} *self = WEBKIT_DOM_${clsCaps}(object); $privFunction +EOF + push(@txtSetProps, $txtSetProps); + } + $txtSetProps = << "EOF"; switch (prop_id) { EOF push(@txtSetProps, $txtSetProps); - # Iterate over the interface attributes and generate a property for - # each one of them. - SKIPENUM: - foreach my $attribute (@{$dataNode->attributes}) { - if (SkipAttribute($attribute)) { - next SKIPENUM; - } - - my $camelPropName = $attribute->signature->name; - my $setPropNameFunction = $codeGenerator->WK_ucfirst($camelPropName); - my $getPropNameFunction = $codeGenerator->WK_lcfirst($camelPropName); - - my $propName = decamelize($camelPropName); - my $propNameCaps = uc($propName); - $propName =~ s/_/-/g; - my ${propEnum} = "PROP_${propNameCaps}"; - push(@cBodyPriv, " ${propEnum},\n"); - - my $propType = $attribute->signature->type; - my ${propGType} = decamelize($propType); - if ($propGType eq "event_target") { - $propGType = "event_target_node"; - } - my ${ucPropGType} = uc($propGType); - - my $gtype = GetGValueTypeName($propType); - my $gparamflag = "WEBKIT_PARAM_READABLE"; - my $writeable = $attribute->type !~ /^readonly/; - my $const = "read-only "; - if ($writeable && $custom) { - $const = "read-only (due to custom functions needed in webkitdom)"; - next SKIPENUM; - } - if ($writeable && !$custom) { - $gparamflag = "WEBKIT_PARAM_READWRITE"; - $const = "read-write "; - } - - my $type = GetGlibTypeName($propType); - $nick = decamelize("${interfaceName}_${propName}"); - $long = "${const} ${type} ${interfaceName}.${propName}"; - - my $convertFunction = ""; - - if ($writeable && ($gtype eq "boolean" || $gtype eq "float" || $gtype eq "double" || - $gtype eq "uint64" || $gtype eq "ulong" || $gtype eq "long" || - $gtype eq "uint" || $gtype eq "ushort" || $gtype eq "uchar" || - $gtype eq "char" || $gtype eq "string")) { - - push(@txtSetProps, " case ${propEnum}:\n {\n"); - push(@txtSetProps, " WebCore::ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; - - if ($gtype eq "string") { - $convertFunction = "WebCore::String::fromUTF8"; - } elsif ($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - $convertFunction = "WebCore::String::number"; - } - - push(@txtSetProps, " coreSelf->set${setPropNameFunction}(${convertFunction}(g_value_get_$gtype(value))"); - push(@txtSetProps, ", ec") if @{$attribute->setterExceptions}; - push(@txtSetProps, ");\n"); - - push(@txtSetProps, " break;\n }\n"); - } - - push(@txtGetProps, " case ${propEnum}:\n {\n"); - - my $exception = ""; - if (@{$attribute->getterExceptions}) { - $exception = "ec"; - push(@txtGetProps, " WebCore::ExceptionCode ec = 0;\n"); - } - - my $postConvertFunction = ""; - my $done = 0; - if ($gtype eq "string") { - push(@txtGetProps, " g_value_take_string(value, convertToUTF8String(coreSelf->${getPropNameFunction}(${exception})));\n"); - $done = 1; - } elsif ($gtype eq "object") { - - $txtGetProp = << "EOF"; - RefPtr<WebCore::${propType}> ptr = coreSelf->${getPropNameFunction}(${exception}); - g_value_set_object(value, WebKit::kit(ptr.get())); -EOF - push(@txtGetProps, $txtGetProp); - - $done = 1; - } - - if($attribute->signature->extendedAttributes->{"ConvertFromString"}) { - # TODO: Add other conversion functions for different types. Current - # IDLs only list longs. - if($gtype eq "long") { - $convertFunction = ""; - $postConvertFunction = ".toInt()"; - } else { - die "Can't convert to type ${gtype}."; - } - } - - # FIXME: get rid of this glitch? - my $_gtype = $gtype; - if ($gtype eq "ushort") { - $_gtype = "uint"; - } - - if (!$done) { - push(@txtGetProps, " g_value_set_$_gtype(value, ${convertFunction}coreSelf->${getPropNameFunction}(${exception})${postConvertFunction});\n"); - } - - push(@txtGetProps, " break;\n }\n"); - -my %param_spec_options = ("int", "G_MININT, /* min */\nG_MAXINT, /* max */\n0, /* default */", - "boolean", "FALSE, /* default */", - "float", "G_MINFLOAT, /* min */\nG_MAXFLOAT, /* max */\n0.0, /* default */", - "double", "G_MINDOUBLE, /* min */\nG_MAXDOUBLE, /* max */\n0.0, /* default */", - "uint64", "0, /* min */\nG_MAXUINT64, /* min */\n0, /* default */", - "long", "G_MINLONG, /* min */\nG_MAXLONG, /* max */\n0, /* default */", - "ulong", "0, /* min */\nG_MAXULONG, /* max */\n0, /* default */", - "uint", "0, /* min */\nG_MAXUINT, /* max */\n0, /* default */", - "ushort", "0, /* min */\nG_MAXUINT16, /* max */\n0, /* default */", - "uchar", "G_MININT8, /* min */\nG_MAXINT8, /* max */\n0, /* default */", - "char", "0, /* min */\nG_MAXUINT8, /* max */\n0, /* default */", - "string", "\"\", /* default */", - "object", "WEBKIT_TYPE_DOM_${ucPropGType}, /* gobject type */"); - - my $txtInstallProp = << "EOF"; - g_object_class_install_property(gobjectClass, - ${propEnum}, - g_param_spec_${_gtype}("${propName}", /* name */ - "$nick", /* short description */ - "$long", /* longer - could do with some extra doc stuff here */ - $param_spec_options{$gtype} - ${gparamflag})); -EOF - push(@txtInstallProps, $txtInstallProp); - $txtInstallProp = "/* TODO! $gtype */\n"; + foreach my $attribute (@readableProperties) { + GenerateProperty($attribute, $interfaceName, \@writeableProperties); } push(@cBodyPriv, "};\n\n"); @@ -483,11 +599,11 @@ EOF push(@hBodyPre, $implContent); - my $clsCaps = uc(decamelize($interfaceName)); - my $lowerCaseIfaceName = "webkit_dom_" . (decamelize($interfaceName)); + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + my $clsCaps = uc($decamelize); + my $lowerCaseIfaceName = "webkit_dom_" . ($decamelize); $implContent = << "EOF"; - #define WEBKIT_TYPE_DOM_${clsCaps} (${lowerCaseIfaceName}_get_type()) #define WEBKIT_DOM_${clsCaps}(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_${clsCaps}, ${className})) #define WEBKIT_DOM_${clsCaps}_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_${clsCaps}, ${className}Class) @@ -517,6 +633,7 @@ sub getIncludeHeader { return "" if $type eq "int"; return "" if $type eq "long"; + return "" if $type eq "long long"; return "" if $type eq "short"; return "" if $type eq "char"; return "" if $type eq "float"; @@ -533,6 +650,7 @@ sub getIncludeHeader { return "" if $type eq "float"; return "" if $type eq "boolean"; return "" if $type eq "void"; + return "" if $type eq "CompareHow"; return "$name.h"; } @@ -540,6 +658,10 @@ sub getIncludeHeader { sub addIncludeInBody { my $type = shift; + if ($type eq "DOMObject") { + return; + } + my $header = getIncludeHeader($type); if ($header eq "") { return; @@ -555,9 +677,15 @@ sub addIncludeInBody { sub GenerateFunction { my ($object, $interfaceName, $function, $prefix) = @_; + my $decamelize = FixUpDecamelizedName(decamelize($interfaceName)); + + if (SkipFunction($function, $decamelize, $prefix)) { + return; + } + my $functionSigName = $function->signature->name; my $functionSigType = $function->signature->type; - my $functionName = "webkit_dom_" . decamelize($interfaceName) . "_" . $prefix . decamelize($functionSigName); + my $functionName = "webkit_dom_" . $decamelize . "_" . $prefix . decamelize($functionSigName); my $returnType = GetGlibTypeName($functionSigType); my $returnValueIsGDOMType = IsGDOMClassType($functionSigType); @@ -571,7 +699,7 @@ sub GenerateFunction { foreach my $param (@{$function->parameters}) { my $paramIDLType = $param->type; - if ($paramIDLType eq "Event") { + if ($paramIDLType eq "Event" || $paramIDLType eq "EventListener") { push(@hBody, "\n/* TODO: event function ${functionName} */\n\n"); push(@cBody, "\n/* TODO: event function ${functionName} */\n\n"); return; @@ -588,7 +716,7 @@ sub GenerateFunction { $implIncludes{"webkit/WebKitDOM${paramIDLType}Private.h"} = 1; } } - if ($paramIsGDOMType || ($paramIDLType eq "DOMString")) { + if ($paramIsGDOMType || ($paramIDLType eq "DOMString") || ($paramIDLType eq "CompareHow")) { $paramName = "_g_" . $paramName; } if ($callImplParams) { @@ -598,13 +726,7 @@ sub GenerateFunction { } } - if ($functionSigType eq "Event") { - push(@hBody, "\n/* TODO: event function ${functionName} */\n\n"); - push(@cBody, "\n/* TODO: event function ${functionName} */\n\n"); - return; - } - - if ($returnType ne "void" && $returnValueIsGDOMType) { + if ($returnType ne "void" && $returnValueIsGDOMType && $functionSigType ne "DOMObject") { if ($functionSigType ne "EventTarget") { $implIncludes{"webkit/WebKitDOM${functionSigType}Private.h"} = 1; $implIncludes{"webkit/WebKitDOM${functionSigType}.h"} = 1; @@ -613,19 +735,6 @@ sub GenerateFunction { $implIncludes{"${functionSigType}.h"} = 1; } - # skip custom functions for now - # but skip from here to allow some headers to be created - # for a successful compile. - if ($isCustomFunction && - $functionName ne "webkit_dom_node_remove_child" && - $functionName ne "webkit_dom_node_insert_before" && - $functionName ne "webkit_dom_node_replace_child" && - $functionName ne "webkit_dom_node_append_child") { - push(@hBody, "\n/* TODO: custom function ${functionName} */\n\n"); - push(@cBody, "\n/* TODO: custom function ${functionName} */\n\n"); - return; - } - if(@{$function->raisesExceptions}) { $functionSig .= ", GError **error"; } @@ -667,8 +776,9 @@ sub GenerateFunction { my $paramIsGDOMType = IsGDOMClassType($paramIDLType); if ($paramIDLType eq "DOMString") { push(@cBody, " WebCore::String _g_${paramName} = WebCore::String::fromUTF8($paramName);\n"); - } - if ($paramIsGDOMType) { + } elsif ($paramIDLType eq "CompareHow") { + push(@cBody, " WebCore::Range::CompareHow _g_${paramName} = static_cast<WebCore::Range::CompareHow>($paramName);\n"); + } elsif ($paramIsGDOMType) { push(@cBody, " WebCore::${paramIDLType} * _g_${paramName} = WebKit::core($paramName);\n"); if ($returnType ne "void") { # TODO: return proper default result @@ -684,7 +794,15 @@ sub GenerateFunction { my $assignPre = ""; my $assignPost = ""; - if ($returnType ne "void" && !$isCustomFunction) { + # We need to special-case these Node methods because their C++ + # signature is different from what we'd expect given their IDL + # description; see Node.h. + my $functionHasCustomReturn = $functionName eq "webkit_dom_node_append_child" || + $functionName eq "webkit_dom_node_insert_before" || + $functionName eq "webkit_dom_node_replace_child" || + $functionName eq "webkit_dom_node_remove_child"; + + if ($returnType ne "void" && !$functionHasCustomReturn) { if ($returnValueIsGDOMType) { $assign = "PassRefPtr<WebCore::${functionSigType}> g_res = "; $assignPre = "WTF::getPtr("; @@ -703,12 +821,7 @@ sub GenerateFunction { } } - # We need to special-case these Node methods because their C++ signature is different - # from what we'd expect given their IDL description; see Node.h. - if ($functionName eq "webkit_dom_node_append_child" || - $functionName eq "webkit_dom_node_insert_before" || - $functionName eq "webkit_dom_node_replace_child" || - $functionName eq "webkit_dom_node_remove_child") { + if ($functionHasCustomReturn) { my $customNodeAppendChild = << "EOF"; bool ok = item->${functionSigName}(${callImplParams}${exceptions}); if (ok) @@ -732,13 +845,40 @@ EOF push(@cBody, "}\n\n"); return; } elsif ($functionSigType eq "DOMString") { - push(@cBody, " ${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n" ); + my $getterContentHead; + my $reflect = $function->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + my $getAttributeFunctionName = $reflectURL ? "getURLAttribute" : "getAttribute"; + $getterContentHead = "${assign}convertToUTF8String(item->${getAttributeFunctionName}(WebCore::${namespace}::${contentAttributeName}Attr));\n"; + } else { + $getterContentHead = "${assign}convertToUTF8String(item->${functionSigName}(${callImplParams}${exceptions}));\n"; + } + + push(@cBody, " ${getterContentHead}"); } else { - push(@cBody, " ${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n" ); + my $setterContentHead; + my $reflect = $function->signature->extendedAttributes->{"Reflect"}; + my $reflectURL = $function->signature->extendedAttributes->{"ReflectURL"}; + if ($reflect || $reflectURL) { + my $contentAttributeName = (($reflect || $reflectURL) eq "1") ? $functionSigName : ($reflect || $reflectURL); + $contentAttributeName =~ s/set//; + $contentAttributeName = $codeGenerator->WK_lcfirst($contentAttributeName); + my $namespace = $codeGenerator->NamespaceForAttributeName($interfaceName, $contentAttributeName); + $implIncludes{"${namespace}.h"} = 1; + $setterContentHead = "${assign}${assignPre}item->setAttribute(WebCore::${namespace}::${contentAttributeName}Attr, ${callImplParams}${exceptions}${assignPost});\n"; + } else { + $setterContentHead = "${assign}${assignPre}item->${functionSigName}(${callImplParams}${exceptions}${assignPost});\n"; + } + + push(@cBody, " ${setterContentHead}"); if(@{$function->raisesExceptions}) { my $exceptionHandling = << "EOF"; - if(ec) { + if (ec) { WebCore::ExceptionCodeDescription ecdesc; WebCore::getExceptionCodeDescription(ec, ecdesc); g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); @@ -748,7 +888,7 @@ EOF } } - if ($returnType ne "void" && !$isCustomFunction) { + if ($returnType ne "void" && !$functionHasCustomReturn) { if ($functionSigType ne "DOMObject") { if ($returnValueIsGDOMType) { push(@cBody, " ${returnType} res = static_cast<${returnType}>(WebKit::kit(g_res.get()));\n"); @@ -813,9 +953,7 @@ sub GenerateFunctions { $function->raisesExceptions($attribute->getterExceptions); $object->GenerateFunction($interfaceName, $function, "get_"); - if ($attribute->type =~ /^readonly/ || - $attribute->signature->extendedAttributes->{"Replaceable"} # can't handle this yet - ) { + if ($attribute->type =~ /^readonly/) { next TOP; } @@ -846,8 +984,8 @@ sub GenerateCFile { my ($object, $interfaceName, $parentClassName, $parentGObjType, $dataNode) = @_; my $implContent = ""; - my $clsCaps = uc(decamelize($interfaceName)); - my $lowerCaseIfaceName = "webkit_dom_" . decamelize($interfaceName); + my $clsCaps = uc(FixUpDecamelizedName(decamelize($interfaceName))); + my $lowerCaseIfaceName = "webkit_dom_" . FixUpDecamelizedName(decamelize($interfaceName)); $implContent = << "EOF"; G_DEFINE_TYPE(${className}, ${lowerCaseIfaceName}, ${parentGObjType}) @@ -962,12 +1100,10 @@ EOF close(PRIVHEADER); } -sub UsesManualToJSImplementation { +sub UsesManualKitImplementation { my $type = shift; - return 1 if $type eq "Node" or $type eq "Document" or $type eq "HTMLCollection" or - $type eq "SVGPathSeg" or $type eq "StyleSheet" or $type eq "CSSRule" or $type eq "CSSValue" or - $type eq "Event" or $type eq "Element" or $type eq "Text"; + return 1 if $type eq "Node" or $type eq "Element"; return 0; } @@ -996,7 +1132,7 @@ sub Generate { $hdrIncludes{"webkit/${parentClassName}.h"} = 1; - if ($className ne "WebKitDOMNode") { + if (!UsesManualKitImplementation($interfaceName)) { my $converter = << "EOF"; namespace WebKit { diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index 919e321..dc21314 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -101,8 +101,13 @@ sub GenerateInterface my $defines = shift; # Start actual generation - $object->GenerateHeader($dataNode); - $object->GenerateImplementation($dataNode); + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } my $name = $dataNode->name; @@ -121,6 +126,25 @@ sub GenerateInterface } } +sub GenerateEventListenerCall +{ + my $className = shift; + my $functionName = shift; + my $passRefPtrHandling = ($functionName eq "add") ? "" : ".get()"; + + $implIncludes{"JSEventListener.h"} = 1; + + my @GenerateEventListenerImpl = (); + push(@GenerateEventListenerImpl, <<END); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->${functionName}EventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec))$passRefPtrHandling, args.at(2).toBoolean(exec)); + return jsUndefined(); +END + return @GenerateEventListenerImpl; +} + # Params: 'idlDocument' struct sub GenerateModule { @@ -168,6 +192,7 @@ sub IndexGetterReturnsStrings sub AddIncludesForType { my $type = $codeGenerator->StripModule(shift); + my $isCallback = @_ ? shift : 0; # When we're finished with the one-file-per-class # reorganization, we won't need these special cases. @@ -180,6 +205,8 @@ sub AddIncludesForType } elsif ($type eq "XPathNSResolver") { $implIncludes{"JSXPathNSResolver.h"} = 1; $implIncludes{"JSCustomXPathNSResolver.h"} = 1; + } elsif ($isCallback) { + $implIncludes{"JS${type}.h"} = 1; } else { # default, include the same named file $implIncludes{"${type}.h"} = 1; @@ -290,6 +317,29 @@ sub prototypeHashTableAccessor } } +sub GenerateConditionalStringFromAttributeValue +{ + my $conditional = shift; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } +} + +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + return GenerateConditionalStringFromAttributeValue($conditional); + } else { + return ""; + } +} + sub GenerateGetOwnPropertySlotBody { my ($dataNode, $interfaceName, $className, $implClassName, $hasAttributes, $inlined) = @_; @@ -475,6 +525,36 @@ sub GenerateGetOwnPropertyDescriptorBody return @getOwnPropertyDescriptorImpl; } +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->name; + + my @headerContentHeader = split("\r", $headerTemplate); + + # - Add header protection + push(@headerContentHeader, "\n#ifndef $className" . "_h"); + push(@headerContentHeader, "\n#define $className" . "_h\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "JS" . $dataNode->name; + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; + push(@implContentHeader, "#include \"$className.h\"\n\n"); + return @implContentHeader; +} + sub GenerateHeader { my $object = shift; @@ -496,22 +576,11 @@ sub GenerateHeader my $hasRealParent = @{$dataNode->parents} > 0; my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; - # - Add default header template - @headerContentHeader = split("\r", $headerTemplate); - - # - Add header protection - push(@headerContentHeader, "\n#ifndef $className" . "_h"); - push(@headerContentHeader, "\n#define $className" . "_h\n\n"); - - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@headerContentHeader, "#if ${conditionalString}\n\n"); - } + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); if ($hasParent) { $headerIncludes{"$parentClassName.h"} = 1; @@ -905,8 +974,9 @@ sub GenerateHeader } } + my $conditionalString = GenerateConditionalString($dataNode); push(@headerContent, "\n} // namespace WebCore\n\n"); - push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditional; + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; push(@headerContent, "#endif\n"); # - Generate dependencies. @@ -916,6 +986,73 @@ sub GenerateHeader } } +sub GenerateAttributesHashTable($$) +{ + my ($object, $dataNode) = @_; + + # FIXME: These should be functions on $dataNode. + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add all attributes in a hashtable definition + my $numAttributes = @{$dataNode->attributes}; + $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); + + return 0 if !$numAttributes; + + my $hashSize = $numAttributes; + my $hashName = $className . "Table"; + + my @hashKeys = (); + my @hashSpecials = (); + my @hashValue1 = (); + my @hashValue2 = (); + my %conditionals = (); + + my @entries = (); + + foreach my $attribute (@{$dataNode->attributes}) { + my $name = $attribute->signature->name; + push(@hashKeys, $name); + + my @specials = (); + push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; + push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; + push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; + my $special = (@specials > 0) ? join("|", @specials) : "0"; + push(@hashSpecials, $special); + + my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue1, $getter); + + if ($attribute->type =~ /readonly/) { + push(@hashValue2, "0"); + } else { + my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); + push(@hashValue2, $setter); + } + + my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; + if ($conditional) { + $conditionals{$name} = $conditional; + } + } + + if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { + push(@hashKeys, "constructor"); + my $getter = "js" . $interfaceName . "Constructor"; + push(@hashValue1, $getter); + push(@hashValue2, "0"); + push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. + } + + $object->GenerateHashTable($hashName, $hashSize, + \@hashKeys, \@hashSpecials, + \@hashValue1, \@hashValue2, + \%conditionals); + return $numAttributes; +} + sub GenerateImplementation { my ($object, $dataNode) = @_; @@ -928,21 +1065,12 @@ sub GenerateImplementation my $hasRealParent = @{$dataNode->parents} > 0; my $hasParent = $hasLegacyParent || $hasRealParent; my $parentClassName = GetParentClassName($dataNode); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $visibleClassName = GetVisibleClassName($interfaceName); my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"}; my $needsMarkChildren = $dataNode->extendedAttributes->{"CustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"}; # - Add default header template - @implContentHeader = split("\r", $headerTemplate); - - push(@implContentHeader, "\n#include \"config.h\"\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContentHeader, "\n#if ${conditionalString}\n\n"); - } - push(@implContentHeader, "#include \"$className.h\"\n\n"); + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); AddIncludesForSVGAnimatedType($interfaceName) if $className =~ /^JSSVGAnimated/; @@ -958,62 +1086,7 @@ sub GenerateImplementation push(@implContent, "ASSERT_CLASS_FITS_IN_CELL($className);\n\n"); - # - Add all attributes in a hashtable definition - my $numAttributes = @{$dataNode->attributes}; - $numAttributes++ if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})); - - if ($numAttributes > 0) { - my $hashSize = $numAttributes; - my $hashName = $className . "Table"; - - my @hashKeys = (); - my @hashSpecials = (); - my @hashValue1 = (); - my @hashValue2 = (); - my %conditionals = (); - - my @entries = (); - - foreach my $attribute (@{$dataNode->attributes}) { - my $name = $attribute->signature->name; - push(@hashKeys, $name); - - my @specials = (); - push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; - push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; - push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; - my $special = (@specials > 0) ? join("|", @specials) : "0"; - push(@hashSpecials, $special); - - my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); - push(@hashValue1, $getter); - - if ($attribute->type =~ /readonly/) { - push(@hashValue2, "0"); - } else { - my $setter = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); - push(@hashValue2, $setter); - } - - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionals{$name} = $conditional; - } - } - - if (!($dataNode->extendedAttributes->{"OmitConstructor"} || $dataNode->extendedAttributes->{"CustomConstructor"})) { - push(@hashKeys, "constructor"); - my $getter = "js" . $interfaceName . "Constructor"; - push(@hashValue1, $getter); - push(@hashValue2, "0"); - push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. - } - - $object->GenerateHashTable($hashName, $hashSize, - \@hashKeys, \@hashSpecials, - \@hashValue1, \@hashValue2, - \%conditionals); - } + my $numAttributes = GenerateAttributesHashTable($object, $dataNode); my $numConstants = @{$dataNode->constants}; my $numFunctions = @{$dataNode->functions}; @@ -1044,7 +1117,7 @@ sub GenerateImplementation my $protoClassName; $protoClassName = "${className}Prototype"; - push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $visibleClassName, $dataNode->extendedAttributes->{"CanBeConstructed"})); + push(@implContent, constructorFor($className, $protoClassName, $interfaceName, $visibleClassName, $dataNode)); } # - Add functions and constants to a hashtable definition @@ -1305,11 +1378,8 @@ sub GenerateImplementation my $getFunctionName = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name); - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContent, "#if ${conditionalString}\n"); - } + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, const Identifier&)\n"); push(@implContent, "{\n"); @@ -1417,9 +1487,7 @@ sub GenerateImplementation push(@implContent, "}\n"); - if ($conditional) { - push(@implContent, "#endif\n"); - } + push(@implContent, "#endif\n") if $attributeConditionalString; push(@implContent, "\n"); } @@ -1486,11 +1554,8 @@ sub GenerateImplementation my $putFunctionName = "setJS" . $interfaceName . $codeGenerator->WK_ucfirst($name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); my $implSetterFunctionName = $codeGenerator->WK_ucfirst($name); - my $conditional = $attribute->signature->extendedAttributes->{"Conditional"}; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContent, "#if ${conditionalString}\n"); - } + my $attributeConditionalString = GenerateConditionalString($attribute->signature); + push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString; push(@implContent, "void ${putFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n"); push(@implContent, "{\n"); @@ -1537,8 +1602,8 @@ sub GenerateImplementation push(@implContent, " // Shadowing a built-in object\n"); push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); } else { - push(@implContent, " $className* castedThisObj = static_cast<$className*>(thisObject);\n"); - push(@implContent, " $implType* imp = static_cast<$implType*>(castedThisObj->impl());\n"); + push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); + push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); if ($podType) { push(@implContent, " $podType podImp(*imp);\n"); if ($podType eq "float") { # Special case for JSSVGNumber @@ -1546,7 +1611,7 @@ sub GenerateImplementation } else { push(@implContent, " podImp.set$implSetterFunctionName(" . JSValueToNative($attribute->signature, "value") . ");\n"); } - push(@implContent, " imp->commitChange(podImp, castedThisObj);\n"); + push(@implContent, " imp->commitChange(podImp, castedThis);\n"); } else { my $nativeValue = JSValueToNative($attribute->signature, "value"); push(@implContent, " ExceptionCode ec = 0;\n") if @{$attribute->setterExceptions}; @@ -1564,16 +1629,14 @@ sub GenerateImplementation push(@implContent, ");\n"); push(@implContent, " setDOMException(exec, ec);\n") if @{$attribute->setterExceptions}; if (IsSVGTypeNeedingContextParameter($implClassName)) { - push(@implContent, " JSSVGContextCache::propagateSVGDOMChange(castedThisObj, imp->associatedAttributeName());\n"); + push(@implContent, " JSSVGContextCache::propagateSVGDOMChange(castedThis, imp->associatedAttributeName());\n"); } } } push(@implContent, "}\n"); - if ($conditional) { - push(@implContent, "#endif\n"); - } + push(@implContent, "#endif\n") if $attributeConditionalString; push(@implContent, "\n"); } @@ -1614,22 +1677,22 @@ sub GenerateImplementation $implIncludes{"<runtime/Error.h>"} = 1; if ($interfaceName eq "DOMWindow") { - push(@implContent, " $className* castedThisObj = toJSDOMWindow(thisValue.toThisObject(exec));\n"); - push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " $className* castedThis = toJSDOMWindow(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThis)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) { - push(@implContent, " $className* castedThisObj = to${className}(thisValue.toThisObject(exec));\n"); - push(@implContent, " if (!castedThisObj)\n"); + push(@implContent, " $className* castedThis = to${className}(thisValue.toThisObject(exec));\n"); + push(@implContent, " if (!castedThis)\n"); push(@implContent, " return throwError(exec, TypeError);\n"); } else { push(@implContent, " if (!thisValue.inherits(&${className}::s_info))\n"); push(@implContent, " return throwError(exec, TypeError);\n"); - push(@implContent, " $className* castedThisObj = static_cast<$className*>(asObject(thisValue));\n"); + push(@implContent, " $className* castedThis = static_cast<$className*>(asObject(thisValue));\n"); } if ($dataNode->extendedAttributes->{"CheckDomainSecurity"} && !$function->signature->extendedAttributes->{"DoNotCheckDomainSecurity"}) { - push(@implContent, " if (!castedThisObj->allowsAccessFrom(exec))\n"); + push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n"); push(@implContent, " return jsUndefined();\n"); } @@ -1649,14 +1712,14 @@ sub GenerateImplementation } if ($function->signature->extendedAttributes->{"Custom"} || $function->signature->extendedAttributes->{"JSCCustom"}) { - push(@implContent, " return castedThisObj->" . $functionImplementationName . "(exec, args);\n"); + push(@implContent, " return castedThis->" . $functionImplementationName . "(exec, args);\n"); } elsif ($svgPODListType) { $implIncludes{"JS${svgPODListType}.h"} = 1; $implIncludes{"JSSVGPODListCustom.h"} = 1; push(@implContent, " return JSSVGPODListCustom::$functionImplementationName<$className, " . GetNativeType($svgPODListType) - . ">(castedThisObj, exec, args, to" . $svgPODListType . ");\n"); + . ">(castedThis, exec, args, to" . $svgPODListType . ");\n"); } else { - push(@implContent, " $implType* imp = static_cast<$implType*>(castedThisObj->impl());\n"); + push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); push(@implContent, " $podType podImp(*imp);\n") if $podType; my $numParameters = @{$function->parameters}; @@ -1676,72 +1739,94 @@ sub GenerateImplementation $implIncludes{"JSDOMBinding.h"} = 1; } - my $paramIndex = 0; - my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; + if ($function->signature->name eq "addEventListener") { + push(@implContent, GenerateEventListenerCall($className, "add")); + } elsif ($function->signature->name eq "removeEventListener") { + push(@implContent, GenerateEventListenerCall($className, "remove")); + } else { + my $paramIndex = 0; + my $functionString = ($podType ? "podImp." : "imp->") . $functionImplementationName . "("; - my $hasOptionalArguments = 0; + my $hasOptionalArguments = 0; - if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); - $implIncludes{"ScriptCallStack.h"} = 1; - } - - foreach my $parameter (@{$function->parameters}) { - if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { - push(@implContent, "\n int argsCount = args.size();\n"); - $hasOptionalArguments = 1; + if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { + push(@implContent, " ScriptCallStack callStack(exec, args, $numParameters);\n"); + $implIncludes{"ScriptCallStack.h"} = 1; } - if ($hasOptionalArguments) { - push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); - GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); - push(@implContent, " }\n\n"); + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + push(@implContent, " Frame* dynamicFrame = toDynamicFrame(exec);\n"); + push(@implContent, " if (!dynamicFrame)\n"); + push(@implContent, " return jsUndefined();\n"); + $callWithArg = "dynamicFrame"; + } elsif ($callWith eq "ScriptState") { + $callWithArg = "exec"; + } + $functionString .= ", " if $paramIndex; + $functionString .= $callWithArg; + $paramIndex++; } - my $name = $parameter->name; + foreach my $parameter (@{$function->parameters}) { + if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { + push(@implContent, "\n int argsCount = args.size();\n"); + $hasOptionalArguments = 1; + } + + if ($hasOptionalArguments) { + push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); + push(@implContent, " }\n\n"); + } + + my $name = $parameter->name; - if ($parameter->type eq "XPathNSResolver") { - push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); - push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n"); - push(@implContent, " if (!resolver) {\n"); - push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n"); - push(@implContent, " if (exec->hadException())\n"); - push(@implContent, " return jsUndefined();\n"); - push(@implContent, " resolver = customResolver.get();\n"); - push(@implContent, " }\n"); - } else { - push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n"); - - # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. - # But this needs to be done in the bindings, because the type is unsigned and the fact that it - # was negative will be lost by the time we're inside the DOM. - if ($parameter->extendedAttributes->{"IsIndex"}) { - $implIncludes{"ExceptionCode.h"} = 1; - push(@implContent, " if ($name < 0) {\n"); - push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); - push(@implContent, " return jsUndefined();\n"); + if ($parameter->type eq "XPathNSResolver") { + push(@implContent, " RefPtr<XPathNSResolver> customResolver;\n"); + push(@implContent, " XPathNSResolver* resolver = toXPathNSResolver(args.at($paramIndex));\n"); + push(@implContent, " if (!resolver) {\n"); + push(@implContent, " customResolver = JSCustomXPathNSResolver::create(exec, args.at($paramIndex));\n"); + push(@implContent, " if (exec->hadException())\n"); + push(@implContent, " return jsUndefined();\n"); + push(@implContent, " resolver = customResolver.get();\n"); push(@implContent, " }\n"); + } else { + push(@implContent, " " . GetNativeTypeFromSignature($parameter) . " $name = " . JSValueToNative($parameter, "args.at($paramIndex)") . ";\n"); + + # If a parameter is "an index" and it's negative it should throw an INDEX_SIZE_ERR exception. + # But this needs to be done in the bindings, because the type is unsigned and the fact that it + # was negative will be lost by the time we're inside the DOM. + if ($parameter->extendedAttributes->{"IsIndex"}) { + $implIncludes{"ExceptionCode.h"} = 1; + push(@implContent, " if ($name < 0) {\n"); + push(@implContent, " setDOMException(exec, INDEX_SIZE_ERR);\n"); + push(@implContent, " return jsUndefined();\n"); + push(@implContent, " }\n"); + } } - } - $functionString .= ", " if $paramIndex; + $functionString .= ", " if $paramIndex; - if ($parameter->type eq "NodeFilter") { - $functionString .= "$name.get()"; - } else { - $functionString .= $name; + if ($parameter->type eq "NodeFilter") { + $functionString .= "$name.get()"; + } else { + $functionString .= $name; + } + $paramIndex++; } - $paramIndex++; - } - if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { - $functionString .= ", " if $paramIndex; - $functionString .= "processingUserGesture(exec)"; - $paramIndex++; - } + if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { + $functionString .= ", " if $paramIndex; + $functionString .= "processingUserGesture(exec)"; + $paramIndex++; + } - push(@implContent, "\n"); - GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName); + push(@implContent, "\n"); + GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " ", $podType, $implClassName); + } } push(@implContent, "}\n\n"); } @@ -1827,7 +1912,156 @@ sub GenerateImplementation push(@implContent, "\n}\n"); - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template and header protection + push(@headerContentHeader, GenerateHeaderContentHeader($dataNode)); + + $headerIncludes{"$interfaceName.h"} = 1; + $headerIncludes{"JSCallbackData.h"} = 1; + $headerIncludes{"<wtf/Forward.h>"} = 1; + + push(@headerContent, "\nnamespace WebCore {\n\n"); + push(@headerContent, "class $className : public $interfaceName {\n"); + push(@headerContent, "public:\n"); + + # The static create() method. + push(@headerContent, " static PassRefPtr<$className> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject)\n"); + push(@headerContent, " {\n"); + push(@headerContent, " return adoptRef(new $className(callback, globalObject));\n"); + push(@headerContent, " }\n\n"); + + # Destructor + push(@headerContent, " virtual ~$className();\n"); + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, "\n // Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if (!$function->signature->extendedAttributes->{"Custom"} && + !(GetNativeType($function->signature->type) eq "bool")) { + push(@headerContent, " COMPILE_ASSERT(false)"); + } + + push(@headerContent, " virtual " . GetNativeType($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + foreach my $param (@params) { + push(@headerContent, ", " . GetNativeType($param->type) . " " . $param->name); + } + + push(@headerContent, ");\n"); + } + } + + push(@headerContent, "\nprivate:\n"); + + # Constructor + push(@headerContent, " $className(JSC::JSObject* callback, JSDOMGlobalObject*);\n\n"); + + # Private members + push(@headerContent, " JSCallbackData* m_data;\n"); + push(@headerContent, " RefPtr<DOMWrapperWorld> m_isolatedWorld;\n"); + push(@headerContent, "};\n\n"); + + push(@headerContent, "} // namespace WebCore\n\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; + push(@headerContent, "#endif\n"); +} + +sub GenerateCallbackImplementation +{ + my ($object, $dataNode) = @_; + + my $interfaceName = $dataNode->name; + my $className = "JS$interfaceName"; + + # - Add default header template + push(@implContentHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"<runtime/JSLock.h>"} = 1; + $implIncludes{"<wtf/MainThread.h>"} = 1; + + @implContent = (); + + push(@implContent, "\nusing namespace JSC;\n\n"); + push(@implContent, "namespace WebCore {\n\n"); + + # Constructor + push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n"); + push(@implContent, " : m_data(new JSCallbackData(callback, globalObject))\n"); + push(@implContent, " , m_isolatedWorld(globalObject->world())\n"); + push(@implContent, "{\n"); + push(@implContent, "}\n\n"); + + # Destructor + push(@implContent, "${className}::~${className}()\n"); + push(@implContent, "{\n"); + push(@implContent, " callOnMainThread(JSCallbackData::deleteData, m_data);\n"); + push(@implContent, "#ifndef NDEBUG\n"); + push(@implContent, " m_data = 0;\n"); + push(@implContent, "#endif\n"); + push(@implContent, "}\n"); + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "\n// Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if ($function->signature->extendedAttributes->{"Custom"} || + !(GetNativeType($function->signature->type) eq "bool")) { + next; + } + + AddIncludesForType($function->signature->type); + push(@implContent, "\n" . GetNativeType($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + + foreach my $param (@params) { + AddIncludesForType($param->type, 1); + push(@implContent, ", " . GetNativeType($param->type) . " " . $param->name); + } + + push(@implContent, ")\n"); + + push(@implContent, "{\n"); + push(@implContent, " ASSERT(m_data);\n"); + push(@implContent, " ASSERT(context);\n\n"); + push(@implContent, " RefPtr<$className> protect(this);\n\n"); + push(@implContent, " JSLock lock(SilenceAssertionsOnly);\n\n"); + push(@implContent, " JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());\n"); + push(@implContent, " if (!globalObject)\n"); + push(@implContent, " return true;\n\n"); + push(@implContent, " ExecState* exec = globalObject->globalExec();\n"); + push(@implContent, " MarkedArgumentBuffer args;\n"); + + foreach my $param (@params) { + my $paramName = $param->name; + push(@implContent, " args.append(toJS(exec, ${paramName}));\n"); + } + + push(@implContent, "\n bool raisedException = false;\n"); + push(@implContent, " m_data->invokeCallback(args, &raisedException);\n"); + push(@implContent, " return !raisedException;\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n}\n"); + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; } sub GenerateImplementationFunctionCall() @@ -1854,16 +2088,22 @@ sub GenerateImplementationFunctionCall() if ($function->signature->type eq "void") { push(@implContent, $indent . "$functionString;\n"); push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; - push(@implContent, $indent . "imp->commitChange(podImp, castedThisObj);\n") if $podType; + push(@implContent, $indent . "imp->commitChange(podImp, castedThis);\n") if $podType; push(@implContent, $indent . "return jsUndefined();\n"); } else { - push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThisObj") . ";\n"); + push(@implContent, "\n" . $indent . "JSC::JSValue result = " . NativeToJSValue($function->signature, 1, $implClassName, "", $functionString, "castedThis") . ";\n"); push(@implContent, $indent . "setDOMException(exec, ec);\n") if @{$function->raisesExceptions}; + $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "ScriptState") { + push(@implContent, $indent . "if (exec->hadException())\n"); + push(@implContent, $indent . " return jsUndefined();\n"); + } + if ($podType and not $function->signature->extendedAttributes->{"Immutable"}) { # Immutable methods do not commit changes back to the instance, thus producing # a new instance rather than mutating existing one. - push(@implContent, $indent . "imp->commitChange(podImp, castedThisObj);\n"); + push(@implContent, $indent . "imp->commitChange(podImp, castedThis);\n"); } push(@implContent, $indent . "return result;\n"); @@ -1888,6 +2128,7 @@ my %nativeType = ( "DOMString" => "const String&", "DOMObject" => "ScriptValue", "NodeFilter" => "RefPtr<NodeFilter>", + "SerializedScriptValue" => "RefPtr<SerializedScriptValue>", "SVGAngle" => "SVGAngle", "SVGLength" => "SVGLength", "SVGMatrix" => "AffineTransform", @@ -1992,6 +2233,8 @@ sub NativeToJSValue die "Unknown value for ConvertNullStringTo extended attribute"; } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "jsOwnedStringOrNull(exec, $value)" if $conv; $implIncludes{"<runtime/JSString.h>"} = 1; return "jsString(exec, $value)"; } @@ -2181,6 +2424,11 @@ tableSizeLoop: # Dump the hash table my $count = scalar @{$keys} + 1; + push(@implContent, "#if ENABLE(JIT)\n"); + push(@implContent, "#define THUNK_GENERATOR(generator) , generator\n"); + push(@implContent, "#else\n"); + push(@implContent, "#define THUNK_GENERATOR(generator)\n"); + push(@implContent, "#endif\n"); push(@implContent, "\nstatic const HashTableValue $nameEntries\[$count\] =\n\{\n"); $i = 0; foreach my $key (@{$keys}) { @@ -2191,7 +2439,7 @@ tableSizeLoop: $conditional = $conditionals->{$key}; } if ($conditional) { - my $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + my $conditionalString = GenerateConditionalStringFromAttributeValue($conditional); push(@implContent, "#if ${conditionalString}\n"); } @@ -2200,14 +2448,15 @@ tableSizeLoop: } else { $targetType = "static_cast<PropertySlot::GetValueFunc>"; } - push(@implContent, " { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] },\n"); + push(@implContent, " { \"$key\", @$specials[$i], (intptr_t)" . $targetType . "(@$value1[$i]), (intptr_t)@$value2[$i] THUNK_GENERATOR(0) },\n"); if ($conditional) { push(@implContent, "#endif\n"); } ++$i; } - push(@implContent, " { 0, 0, 0, 0 }\n"); + push(@implContent, " { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n"); push(@implContent, "};\n\n"); + push(@implContent, "#undef THUNK_GENERATOR\n"); my $perfectSizeMask = $perfectSize - 1; my $compactSizeMask = $numEntries - 1; push(@implContent, "static JSC_CONST_HASHTABLE HashTable $name =\n"); @@ -2350,8 +2599,10 @@ sub constructorFor my $protoClassName = shift; my $interfaceName = shift; my $visibleClassName = shift; - my $canConstruct = shift; + my $dataNode = shift; my $constructorClassName = "${className}Constructor"; + my $canConstruct = $dataNode->extendedAttributes->{"CanBeConstructed"}; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; my $implContent = << "EOF"; class ${constructorClassName} : public DOMConstructorObject { @@ -2379,7 +2630,20 @@ EOF $implContent .= << "EOF"; static JSObject* construct${interfaceName}(ExecState* exec, JSObject* constructor, const ArgList&) { - return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create())); +EOF + + my $constructorArg = ""; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $constructorArg = "context"; +$implContent .= << "EOF"; + ScriptExecutionContext* context = static_cast<${constructorClassName}*>(constructor)->scriptExecutionContext(); + if (!context) + return throwError(exec, ReferenceError); +EOF + } + +$implContent .= << "EOF"; + return asObject(toJS(exec, static_cast<${constructorClassName}*>(constructor)->globalObject(), ${interfaceName}::create(${constructorArg}))); } virtual ConstructType getConstructData(ConstructData& constructData) { diff --git a/WebCore/bindings/scripts/CodeGeneratorObjC.pm b/WebCore/bindings/scripts/CodeGeneratorObjC.pm index 3c5fe45..7132e22 100644 --- a/WebCore/bindings/scripts/CodeGeneratorObjC.pm +++ b/WebCore/bindings/scripts/CodeGeneratorObjC.pm @@ -269,6 +269,23 @@ sub ReadPublicInterfaces $interfaceAvailabilityVersion = "WEBKIT_VERSION_LATEST" if $newPublicClass; } +sub GenerateConditionalString +{ + my $node = shift; + my $conditional = $node->extendedAttributes->{"Conditional"}; + if ($conditional) { + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } + } else { + return ""; + } +} + # Params: 'domClass' struct sub GenerateInterface { @@ -1014,7 +1031,6 @@ sub GenerateImplementation my $implClassNameWithNamespace = "WebCore::" . $implClassName; my $baseClass = GetBaseClass($parentImplClassName); my $classHeaderName = GetClassHeaderName($className); - my $conditional = $dataNode->extendedAttributes->{"Conditional"}; my $numAttributes = @{$dataNode->attributes}; my $numFunctions = @{$dataNode->functions}; @@ -1032,11 +1048,8 @@ sub GenerateImplementation # - INCLUDES - push(@implContentHeader, "\n#import \"config.h\"\n"); - my $conditionalString; - if ($conditional) { - $conditionalString = "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; - push(@implContentHeader, "\n#if ${conditionalString}\n\n"); - } + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContentHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; push(@implContentHeader, "#import \"DOMInternal.h\"\n\n"); push(@implContentHeader, "#import \"$classHeaderName.h\"\n\n"); @@ -1585,7 +1598,7 @@ sub GenerateImplementation } # - End the ifdef conditional if necessary - push(@implContent, "\n#endif // ${conditionalString}\n") if $conditional; + push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; # - Generate dependencies. if ($writeDependencies && @ancestorInterfaceNames) { diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 1c5f398..9553b8b 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -99,8 +99,13 @@ sub GenerateInterface my $defines = shift; # Start actual generation - $object->GenerateHeader($dataNode); - $object->GenerateImplementation($dataNode); + if ($dataNode->extendedAttributes->{"Callback"}) { + $object->GenerateCallbackHeader($dataNode); + $object->GenerateCallbackImplementation($dataNode); + } else { + $object->GenerateHeader($dataNode); + $object->GenerateImplementation($dataNode); + } my $name = $dataNode->name; @@ -189,7 +194,13 @@ sub GenerateConditionalString my $node = shift; my $conditional = $node->extendedAttributes->{"Conditional"}; if ($conditional) { - return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + if ($conditional =~ /&/) { + return "ENABLE(" . join(") && ENABLE(", split(/&/, $conditional)) . ")"; + } elsif ($conditional =~ /\|/) { + return "ENABLE(" . join(") || ENABLE(", split(/\|/, $conditional)) . ")"; + } else { + return "ENABLE(" . $conditional . ")"; + } } else { return ""; } @@ -226,14 +237,9 @@ sub GenerateHeader $codeGenerator->AddMethodsConstantsAndAttributesFromParentClasses($dataNode, \@allParents, 1); my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template - @headerContent = split("\r", $headerTemplate); - - push(@headerContent, "\n#if ${conditionalString}\n\n") if $conditionalString; - push(@headerContent, "\n#ifndef $className" . "_h"); - push(@headerContent, "\n#define $className" . "_h\n\n"); + push(@headerContent, GenerateHeaderContentHeader($dataNode)); # Get correct pass/store types respecting PODType flag my $podType = $dataNode->extendedAttributes->{"PODType"}; @@ -351,6 +357,7 @@ END push(@headerContent, "}\n\n"); push(@headerContent, "#endif // $className" . "_h\n"); + my $conditionalString = GenerateConditionalString($dataNode); push(@headerContent, "#endif // ${conditionalString}\n\n") if $conditionalString; } @@ -1218,7 +1225,8 @@ END if ($parameter->type eq "SerializedScriptValue") { push(@implContentDecls, "SerializedScriptValue::create(args[$paramIndex], ${parameterName}DidThrow);\n"); - push(@implContentDecls, " if (${parameterName}DidThrow)\n return v8::Undefined();\n"); + push(@implContentDecls, " if (${parameterName}DidThrow)\n"); + push(@implContentDecls, " return v8::Undefined();\n"); } else { push(@implContentDecls, JSValueToNative($parameter, "args[$paramIndex]", BasicTypeCanFailConversion($parameter) ? "${parameterName}Ok" : undef) . ";\n"); @@ -1570,16 +1578,9 @@ sub GenerateImplementation my $implClassName = $interfaceName; my $hasLegacyParent = $dataNode->extendedAttributes->{"LegacyParent"}; - my $conditionalString = GenerateConditionalString($dataNode); # - Add default header template - @implContentHeader = split("\r", $headerTemplate); - - push(@implFixedHeader, - "\n#include \"config.h\"\n" . - "#include \"${className}.h\"\n\n"); - - push(@implFixedHeader, "\n#if ${conditionalString}\n\n") if $conditionalString; + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); $implIncludes{"RuntimeEnabledFeatures.h"} = 1; $implIncludes{"V8Proxy.h"} = 1; @@ -1780,11 +1781,18 @@ END # In namespace WebCore, add generated implementation for 'CanBeConstructed'. if ($dataNode->extendedAttributes->{"CanBeConstructed"} && !$dataNode->extendedAttributes->{"CustomConstructor"}) { + my $v8ConstructFunction; + my $callWith = $dataNode->extendedAttributes->{"CallWith"}; + if ($callWith and $callWith eq "ScriptExecutionContext") { + $v8ConstructFunction = "constructDOMObjectWithScriptExecutionContext"; + } else { + $v8ConstructFunction = "constructDOMObject"; + } push(@implContent, <<END); v8::Handle<v8::Value> ${className}::constructorCallback(const v8::Arguments& args) { INC_STATS("DOM.${interfaceName}.Contructor"); - return V8Proxy::constructDOMObject<$interfaceName>(args, &info); + return V8Proxy::${v8ConstructFunction}<$interfaceName>(args, &info); } END } @@ -2087,6 +2095,7 @@ END } // namespace WebCore END + my $conditionalString = GenerateConditionalString($dataNode); push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString; # We've already added the header for this file in implFixedHeader, so remove @@ -2094,6 +2103,190 @@ END delete $implIncludes{"${className}.h"}; } +sub GenerateHeaderContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @headerContentHeader = split("\r", $headerTemplate); + + push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString; + push(@headerContentHeader, "\n#ifndef ${className}" . "_h"); + push(@headerContentHeader, "\n#define ${className}" . "_h\n\n"); + return @headerContentHeader; +} + +sub GenerateImplementationContentHeader +{ + my $dataNode = shift; + my $className = "V8" . $dataNode->name; + my $conditionalString = GenerateConditionalString($dataNode); + + my @implContentHeader = split("\r", $headerTemplate); + + push(@implContentHeader, "\n#include \"config.h\"\n"); + push(@implContentHeader, "#include \"${className}.h\"\n\n"); + push(@implContentHeader, "#if ${conditionalString}\n\n") if $conditionalString; + return @implContentHeader; +} + +sub GenerateCallbackHeader +{ + my $object = shift; + my $dataNode = shift; + + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + + # - Add default header template + push(@headerContent, GenerateHeaderContentHeader($dataNode)); + + if ("$interfaceName.h" lt "WorldContextHandle.h") { + push(@headerContent, "#include \"$interfaceName.h\"\n"); + push(@headerContent, "#include \"WorldContextHandle.h\"\n"); + } else { + push(@headerContent, "#include \"WorldContextHandle.h\"\n"); + push(@headerContent, "#include \"$interfaceName.h\"\n"); + } + push(@headerContent, "#include <v8.h>\n"); + push(@headerContent, "#include <wtf/Forward.h>\n"); + + push(@headerContent, "\nnamespace WebCore {\n\n"); + push(@headerContent, "class Frame;\n\n"); + push(@headerContent, "class $className : public $interfaceName {\n"); + + push(@headerContent, <<END); +public: + static PassRefPtr<${className}> create(v8::Local<v8::Value> value, Frame* frame) + { + ASSERT(value->IsObject()); + return adoptRef(new ${className}(value->ToObject(), frame)); + } + + virtual ~${className}(); + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@headerContent, " // Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if (!$function->signature->extendedAttributes->{"Custom"} && + !(GetNativeType($function->signature->type) eq "bool")) { + push(@headerContent, " COMPILE_ASSERT(false)"); + } + + push(@headerContent, " virtual " . GetNativeTypeForCallbacks($function->signature->type) . " " . $function->signature->name . "(ScriptExecutionContext*"); + foreach my $param (@params) { + push(@headerContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + } + + push(@headerContent, ");\n"); + } + } + + push(@headerContent, <<END); + +private: + ${className}(v8::Local<v8::Object>, Frame*); + + v8::Persistent<v8::Object> m_callback; + RefPtr<Frame> m_frame; + WorldContextHandle m_worldContext; +}; + +END + + push(@headerContent, "}\n\n"); + push(@headerContent, "#endif // $className" . "_h\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@headerContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + +sub GenerateCallbackImplementation +{ + my $object = shift; + my $dataNode = shift; + my $interfaceName = $dataNode->name; + my $className = "V8$interfaceName"; + + # - Add default header template + push(@implFixedHeader, GenerateImplementationContentHeader($dataNode)); + + $implIncludes{"Frame.h"} = 1; + $implIncludes{"ScriptExecutionContext.h"} = 1; + $implIncludes{"V8CustomVoidCallback.h"} = 1; + + push(@implContent, "namespace WebCore {\n\n"); + push(@implContent, <<END); +${className}::${className}(v8::Local<v8::Object> callback, Frame* frame) + : m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_frame(frame) + , m_worldContext(UseCurrentWorld) +{ +} + +${className}::~${className}() +{ + m_callback.Dispose(); +} + +END + + # Functions + my $numFunctions = @{$dataNode->functions}; + if ($numFunctions > 0) { + push(@implContent, "// Functions\n"); + foreach my $function (@{$dataNode->functions}) { + my @params = @{$function->parameters}; + if ($function->signature->extendedAttributes->{"Custom"} || + !(GetNativeTypeForCallbacks($function->signature->type) eq "bool")) { + next; + } + + AddIncludesForType($function->signature->type); + push(@implContent, "\n" . GetNativeTypeForCallbacks($function->signature->type) . " ${className}::" . $function->signature->name . "(ScriptExecutionContext* context"); + + foreach my $param (@params) { + AddIncludesForType($param->type); + push(@implContent, ", " . GetNativeTypeForCallbacks($param->type) . " " . $param->name); + } + + push(@implContent, ")\n"); + push(@implContent, "{\n"); + push(@implContent, " v8::HandleScope handleScope;\n\n"); + push(@implContent, " v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext);\n"); + push(@implContent, " if (v8Context.IsEmpty())\n"); + push(@implContent, " return true;\n\n"); + push(@implContent, " v8::Context::Scope scope(v8Context);\n\n"); + push(@implContent, " v8::Handle<v8::Value> argv[] = {\n"); + + my @argvs = (); + foreach my $param (@params) { + my $paramName = $param->name; + push(@argvs, " toV8(${paramName})"); + } + push(@implContent, join(",\n", @argvs)); + + push(@implContent, "\n };\n\n"); + push(@implContent, " RefPtr<Frame> protect(m_frame);\n\n"); + push(@implContent, " bool callbackReturnValue = false;\n"); + push(@implContent, " return !invokeCallback(m_callback, " . scalar(@params). ", argv, callbackReturnValue);\n"); + push(@implContent, "}\n"); + } + } + + push(@implContent, "\n} // namespace WebCore\n\n"); + + my $conditionalString = GenerateConditionalString($dataNode); + push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString; +} + sub GenerateToV8Converters { my $dataNode = shift; @@ -2326,15 +2519,33 @@ sub GenerateFunctionCallString() $functionString = "listImp->${name}("; } - my $first = 1; my $index = 0; + my $hasScriptState = 0; + + my $callWith = $function->signature->extendedAttributes->{"CallWith"}; + if ($callWith) { + my $callWithArg = "COMPILE_ASSERT(false)"; + if ($callWith eq "DynamicFrame") { + $result .= $indent . "Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext();\n"; + $result .= $indent . "if (!enteredFrame)\n"; + $result .= $indent . " return v8::Undefined();\n"; + $callWithArg = "enteredFrame"; + } elsif ($callWith eq "ScriptState") { + $result .= $indent . "EmptyScriptState state;\n"; + $callWithArg = "&state"; + $hasScriptState = 1; + } + $functionString .= ", " if $index; + $functionString .= $callWithArg; + $index++; + $numberOfParameters++ + } foreach my $parameter (@{$function->parameters}) { if ($index eq $numberOfParameters) { last; } - if ($first) { $first = 0; } - else { $functionString .= ", "; } + $functionString .= ", " if $index; my $paramName = $parameter->name; my $paramType = $parameter->type; @@ -2353,22 +2564,23 @@ sub GenerateFunctionCallString() } if ($function->signature->extendedAttributes->{"CustomArgumentHandling"}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; $functionString .= "callStack.get()"; - if ($first) { $first = 0; } + $index++; } if ($function->signature->extendedAttributes->{"NeedsUserGestureCheck"}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; # FIXME: We need to pass DOMWrapperWorld as a parameter. # See http://trac.webkit.org/changeset/54182 $functionString .= "processingUserGesture()"; - if ($first) { $first = 0; } + $index++; } if (@{$function->raisesExceptions}) { - $functionString .= ", " if not $first; + $functionString .= ", " if $index; $functionString .= "ec"; + $index++; } $functionString .= ")"; @@ -2381,7 +2593,7 @@ sub GenerateFunctionCallString() $result .= $indent . GetNativeType($returnType, 0) . " result = *imp;\n" . $indent . "$functionString;\n"; } elsif ($returnsListItemPodType) { $result .= $indent . "RefPtr<SVGPODListItem<$nativeReturnType> > result = $functionString;\n"; - } elsif (@{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) { + } elsif ($hasScriptState or @{$function->raisesExceptions} or $returnsPodType or $isPodType or IsSVGTypeNeedingContextParameter($returnType)) { $result .= $indent . $nativeReturnType . " result = $functionString;\n"; } else { # Can inline the function call into the return statement to avoid overhead of using a Ref<> temporary @@ -2390,7 +2602,13 @@ sub GenerateFunctionCallString() } if (@{$function->raisesExceptions}) { - $result .= $indent . "if (UNLIKELY(ec))\n" . $indent . " goto fail;\n"; + $result .= $indent . "if (UNLIKELY(ec))\n"; + $result .= $indent . " goto fail;\n"; + } + + if ($hasScriptState) { + $result .= $indent . "if (state.hadException())\n"; + $result .= $indent . " return throwError(state.exception());\n" } # If the return type is a POD type, separate out the wrapper generation @@ -2537,6 +2755,8 @@ sub GetNativeType # temporary hack return "RefPtr<NodeFilter>" if $type eq "NodeFilter"; + return "RefPtr<SerializedScriptValue>" if $type eq "SerializedScriptValue"; + # necessary as resolvers could be constructed on fly. return "RefPtr<XPathNSResolver>" if $type eq "XPathNSResolver"; @@ -2546,6 +2766,15 @@ sub GetNativeType return "${type}*"; } +sub GetNativeTypeForCallbacks +{ + my $type = shift; + return "const String&" if $type eq "DOMString"; + + # Callbacks use raw pointers, so pass isParameter = 1 + return GetNativeType($type, 1); +} + sub TranslateParameter { my $signature = shift; @@ -2735,6 +2964,7 @@ sub RequiresCustomSignature } +# FIXME: Sort this array. my %non_wrapper_types = ( 'float' => 1, 'double' => 1, @@ -2749,6 +2979,7 @@ my %non_wrapper_types = ( 'unsigned long long' => 1, 'DOMString' => 1, 'CompareHow' => 1, + 'SerializedScriptValue' => 1, 'SVGAngle' => 1, 'SVGRect' => 1, 'SVGPoint' => 1, @@ -2821,6 +3052,8 @@ sub ReturnNativeToJSValue return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned"; return "return v8DateOrNull($value)" if $type eq "Date"; + # long long and unsigned long long are not representable in ECMAScript. + return "return v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long"; return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; return "return $value.v8Value()" if $nativeType eq "ScriptValue"; @@ -2833,6 +3066,8 @@ sub ReturnNativeToJSValue die "Unknown value for ConvertNullStringTo extended attribute"; } + $conv = $signature->extendedAttributes->{"ConvertScriptString"}; + return "v8StringOrNull(exec, $value)" if $conv; return "return v8String($value)"; } diff --git a/WebCore/bindings/scripts/IDLParser.pm b/WebCore/bindings/scripts/IDLParser.pm index 7db7747..c6742dc 100644 --- a/WebCore/bindings/scripts/IDLParser.pm +++ b/WebCore/bindings/scripts/IDLParser.pm @@ -80,10 +80,11 @@ sub Parse print " | *** Starting to parse $fileName...\n |\n" unless $beQuiet; - open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName); + $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), (map { "-D$_" } split(' ', $defines)), $fileName); close PP_IN; my @documentContent = <PP_OUT>; close PP_OUT; + waitpid($pid, 0); my $dataAvailable = 0; diff --git a/WebCore/bindings/scripts/IDLStructure.pm b/WebCore/bindings/scripts/IDLStructure.pm index 6224e54..e060252 100644 --- a/WebCore/bindings/scripts/IDLStructure.pm +++ b/WebCore/bindings/scripts/IDLStructure.pm @@ -96,7 +96,7 @@ $typeNamespaceSelector = '((?:' . $idlId . '*::)*)\s*(' . $idlDataType . '*)'; $exceptionSelector = 'exception\s*(' . $idlIdNs . '*)\s*([a-zA-Z\s{;]*};)'; $exceptionSubSelector = '{\s*' . $supportedTypes . '\s*(' . $idlType . '*)\s*;\s*}'; -$interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([a-zA-Z0-9_=\s(),;:\[\]]*)'; +$interfaceSelector = 'interface\s*((?:' . $extendedAttributeSyntax . ' )?)(' . $idlIdNs . '*)\s*(?::(\s*[^{]*))?{([a-zA-Z0-9_=\s(),;:\[\]&\|]*)'; $interfaceMethodSelector = '\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)\s*\(\s*([a-zA-Z0-9:\s,=\[\]]*)'; $interfaceParameterSelector = 'in\s*((?:' . $extendedAttributeSyntax . ' )?)' . $supportedTypes . '\s*(' . $idlIdNs . '*)'; diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp new file mode 100644 index 0000000..6cfec74 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.cpp @@ -0,0 +1,186 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestCallback.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMClass1.h" +#include "webkit/WebKitDOMClass1Private.h" +#include "webkit/WebKitDOMClass2.h" +#include "webkit/WebKitDOMClass2Private.h" +#include "webkit/WebKitDOMClass3.h" +#include "webkit/WebKitDOMClass3Private.h" +#include "webkit/WebKitDOMTestCallback.h" +#include "webkit/WebKitDOMTestCallbackPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestCallback* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestCallback(obj)); +} + +} // namespace WebKit // + +gboolean +webkit_dom_test_callback_callback_with_class1param (WebKitDOMTestCallback *self, WebKitDOMClass1* class1param) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class1param, 0); + WebCore::Class1 * _g_class1param = WebKit::core(class1param); + g_return_val_if_fail (_g_class1param, 0); + gboolean res = item->callbackWithClass1Param(_g_class1param); + return res; + +} + +gboolean +webkit_dom_test_callback_callback_with_class2param (WebKitDOMTestCallback *self, WebKitDOMClass2* class2param, gchar* str_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class2param, 0); + g_return_val_if_fail (str_arg, 0); + WebCore::Class2 * _g_class2param = WebKit::core(class2param); + g_return_val_if_fail (_g_class2param, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + gboolean res = item->callbackWithClass2Param(_g_class2param, _g_str_arg); + return res; + +} + +glong +webkit_dom_test_callback_callback_with_non_bool_return_type (WebKitDOMTestCallback *self, WebKitDOMClass3* class3param) +{ + g_return_val_if_fail (self, 0); + WebCore::TestCallback * item = WebKit::core(self); + g_return_val_if_fail (class3param, 0); + WebCore::Class3 * _g_class3param = WebKit::core(class3param); + g_return_val_if_fail (_g_class3param, 0); + glong res = item->callbackWithNonBoolReturnType(_g_class3param); + return res; + +} + + +G_DEFINE_TYPE(WebKitDOMTestCallback, webkit_dom_test_callback, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestCallback* wrapTestCallback(WebCore::TestCallback* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestCallback* wrapper = WEBKIT_DOM_TEST_CALLBACK(g_object_new(WEBKIT_TYPE_DOM_TEST_CALLBACK, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestCallback* core(WebKitDOMTestCallback* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_callback_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestCallback* coreObject = static_cast<WebCore::TestCallback *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_callback_parent_class)->finalize(object); +} + +static void webkit_dom_test_callback_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_callback_class_init(WebKitDOMTestCallbackClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_callback_finalize; + gobjectClass->set_property = webkit_dom_test_callback_set_property; + gobjectClass->get_property = webkit_dom_test_callback_get_property; + + + + +} + +static void webkit_dom_test_callback_init(WebKitDOMTestCallback* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h new file mode 100644 index 0000000..088c457 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallback.h @@ -0,0 +1,60 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestCallback_h +#define WebKitDOMTestCallback_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_CALLBACK (webkit_dom_test_callback_get_type()) +#define WEBKIT_DOM_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallback)) +#define WEBKIT_DOM_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass) +#define WEBKIT_DOM_IS_TEST_CALLBACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_IS_TEST_CALLBACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_CALLBACK)) +#define WEBKIT_DOM_TEST_CALLBACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_CALLBACK, WebKitDOMTestCallbackClass)) + +struct _WebKitDOMTestCallback { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestCallbackClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_callback_get_type (void); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class1param (WebKitDOMTestCallback *self, WebKitDOMClass1* class1param); + +WEBKIT_API gboolean +webkit_dom_test_callback_callback_with_class2param (WebKitDOMTestCallback *self, WebKitDOMClass2* class2param, gchar* str_arg); + +WEBKIT_API glong +webkit_dom_test_callback_callback_with_non_bool_return_type (WebKitDOMTestCallback *self, WebKitDOMClass3* class3param); + +G_END_DECLS + +#endif /* WebKitDOMTestCallback_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h new file mode 100644 index 0000000..45884b2 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestCallbackPrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H +#define WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestCallback.h" +namespace WebKit { + WebKitDOMTestCallback * + wrapTestCallback(WebCore::TestCallback *coreObject); + + WebCore::TestCallback * + core(WebKitDOMTestCallback *request); + + gpointer + kit(WebCore::TestCallback* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_CALLBACK_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp new file mode 100644 index 0000000..2be0277 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.cpp @@ -0,0 +1,139 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestInterface.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMTestInterface.h" +#include "webkit/WebKitDOMTestInterfacePrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestInterface* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestInterface(obj)); +} + +} // namespace WebKit // + + +G_DEFINE_TYPE(WebKitDOMTestInterface, webkit_dom_test_interface, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestInterface* wrapTestInterface(WebCore::TestInterface* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestInterface* wrapper = WEBKIT_DOM_TEST_INTERFACE(g_object_new(WEBKIT_TYPE_DOM_TEST_INTERFACE, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestInterface* core(WebKitDOMTestInterface* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, +}; + + +static void webkit_dom_test_interface_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestInterface* coreObject = static_cast<WebCore::TestInterface *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_interface_parent_class)->finalize(object); +} + +static void webkit_dom_test_interface_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_interface_class_init(WebKitDOMTestInterfaceClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_interface_finalize; + gobjectClass->set_property = webkit_dom_test_interface_set_property; + gobjectClass->get_property = webkit_dom_test_interface_get_property; + + + + +} + +static void webkit_dom_test_interface_init(WebKitDOMTestInterface* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h new file mode 100644 index 0000000..f9af866 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterface.h @@ -0,0 +1,51 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestInterface_h +#define WebKitDOMTestInterface_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_INTERFACE (webkit_dom_test_interface_get_type()) +#define WEBKIT_DOM_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterface)) +#define WEBKIT_DOM_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass) +#define WEBKIT_DOM_IS_TEST_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_IS_TEST_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_INTERFACE)) +#define WEBKIT_DOM_TEST_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_INTERFACE, WebKitDOMTestInterfaceClass)) + +struct _WebKitDOMTestInterface { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestInterfaceClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_interface_get_type (void); + +G_END_DECLS + +#endif /* WebKitDOMTestInterface_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h new file mode 100644 index 0000000..45fb949 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestInterfacePrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H +#define WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestInterface.h" +namespace WebKit { + WebKitDOMTestInterface * + wrapTestInterface(WebCore::TestInterface *coreObject); + + WebCore::TestInterface * + core(WebKitDOMTestInterface *request); + + gpointer + kit(WebCore::TestInterface* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_INTERFACE_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp new file mode 100644 index 0000000..8c1bae2 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -0,0 +1,779 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <glib-object.h> +#include "config.h" + +#include <wtf/GetPtr.h> +#include <wtf/RefPtr.h> +#include "ExceptionCode.h" +#include "TestObj.h" +#include "WebKitDOMBinding.h" +#include "gobject/ConvertToUTF8String.h" +#include "webkit/WebKitDOMSerializedScriptValue.h" +#include "webkit/WebKitDOMSerializedScriptValuePrivate.h" +#include "webkit/WebKitDOMTestObj.h" +#include "webkit/WebKitDOMTestObjPrivate.h" +#include "webkitmarshal.h" +#include "webkitprivate.h" + +namespace WebKit { + +gpointer kit(WebCore::TestObj* obj) +{ + g_return_val_if_fail(obj != 0, 0); + + if (gpointer ret = DOMObjectCache::get(obj)) + return ret; + + return DOMObjectCache::put(obj, WebKit::wrapTestObj(obj)); +} + +} // namespace WebKit // + +void +webkit_dom_test_obj_void_method (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->voidMethod(); + +} + +void +webkit_dom_test_obj_void_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (str_arg); + g_return_if_fail (obj_arg); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_if_fail (_g_obj_arg); + item->voidMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + +} + +glong +webkit_dom_test_obj_int_method (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intMethod(); + return res; + +} + +glong +webkit_dom_test_obj_int_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + glong res = item->intMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethod()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->objMethodWithArgs(int_arg, _g_str_arg, _g_obj_arg)); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (serialized_arg); + WebCore::SerializedScriptValue * _g_serialized_arg = WebKit::core(serialized_arg); + g_return_if_fail (_g_serialized_arg); + item->serializedValue(_g_serialized_arg); + +} + +void +webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->methodWithException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + +} + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +void +webkit_dom_test_obj_with_dynamic_frame (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrame(); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_arg (WebKitDOMTestObj *self, glong int_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndArg(int_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg (WebKitDOMTestObj *self, glong int_arg, glong optional_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndOptionalArg(int_arg, optional_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture (WebKitDOMTestObj *self, glong int_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGesture(int_arg); + +} + +void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad (WebKitDOMTestObj *self, glong int_arg, glong optional_arg) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withDynamicFrameAndUserGestureASAD(int_arg, optional_arg); + +} + +void +webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->withScriptStateVoid(); + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObj()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + item->withScriptStateVoidException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + WebCore::ExceptionCode ec = 0; + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->withScriptStateObjException(ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithOptionalArg(opt); + +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg (WebKitDOMTestObj *self, glong non_opt, glong opt) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndOptionalArg(non_opt, opt); + +} + +void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args (WebKitDOMTestObj *self, glong non_opt, glong opt1, glong opt2) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->methodWithNonOptionalArgAndTwoOptionalArgs(non_opt, opt1, opt2); + +} + +glong +webkit_dom_test_obj_get_read_only_int_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->readOnlyIntAttr(); + return res; + +} + +gchar* +webkit_dom_test_obj_get_read_only_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->readOnlyStringAttr()); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->readOnlyTestObjAttr()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +glong +webkit_dom_test_obj_get_int_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->intAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_int_attr (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setIntAttr(value); + +} + +gint64 +webkit_dom_test_obj_get_long_long_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gint64 res = item->longLongAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_long_long_attr (WebKitDOMTestObj *self, gint64 value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setLongLongAttr(value); + +} + +guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + guint64 res = item->unsignedLongLongAttr(); + return res; + +} + +void +webkit_dom_test_obj_set_unsigned_long_long_attr (WebKitDOMTestObj *self, guint64 value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setUnsignedLongLongAttr(value); + +} + +gchar* +webkit_dom_test_obj_get_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->stringAttr()); + return res; + +} + +void +webkit_dom_test_obj_set_string_attr (WebKitDOMTestObj *self, gchar* value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (value); + WebCore::String _g_value = WebCore::String::fromUTF8(value); + item->setStringAttr(_g_value); + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->testObjAttr()); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +void +webkit_dom_test_obj_set_test_obj_attr (WebKitDOMTestObj *self, WebKitDOMTestObj* value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + g_return_if_fail (value); + WebCore::TestObj * _g_value = WebKit::core(value); + g_return_if_fail (_g_value); + item->setTestObjAttr(_g_value); + +} + +glong +webkit_dom_test_obj_get_attr_with_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithException(value); + +} + +glong +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithSetterException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithSetterException(value); + +} + +glong +webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + glong res = item->attrWithGetterException(); + return res; + +} + +void +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value) +{ + g_return_if_fail (self); + WebCore::TestObj * item = WebKit::core(self); + item->setAttrWithGetterException(value); + +} + +gchar* +webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + gchar* res = convertToUTF8String(item->scriptStringAttr()); + return res; + +} + + +G_DEFINE_TYPE(WebKitDOMTestObj, webkit_dom_test_obj, WEBKIT_TYPE_DOM_OBJECT) + +namespace WebKit { + +WebKitDOMTestObj* wrapTestObj(WebCore::TestObj* coreObject) +{ + g_return_val_if_fail(coreObject != 0, 0); + + WebKitDOMTestObj* wrapper = WEBKIT_DOM_TEST_OBJ(g_object_new(WEBKIT_TYPE_DOM_TEST_OBJ, NULL)); + g_return_val_if_fail(wrapper != 0, 0); + + /* We call ref() rather than using a C++ smart pointer because we can't store a C++ object + * in a C-allocated GObject structure. See the finalize() code for the + * matching deref(). + */ + + coreObject->ref(); + WEBKIT_DOM_OBJECT(wrapper)->coreObject = coreObject; + + return wrapper; +} + +WebCore::TestObj* core(WebKitDOMTestObj* request) +{ + g_return_val_if_fail(request != 0, 0); + + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj*>(WEBKIT_DOM_OBJECT(request)->coreObject); + g_return_val_if_fail(coreObject != 0, 0); + + return coreObject; +} + +} // namespace WebKit +enum { + PROP_0, + PROP_READ_ONLY_INT_ATTR, + PROP_READ_ONLY_STRING_ATTR, + PROP_READ_ONLY_TEST_OBJ_ATTR, + PROP_INT_ATTR, + PROP_LONG_LONG_ATTR, + PROP_UNSIGNED_LONG_LONG_ATTR, + PROP_STRING_ATTR, + PROP_TEST_OBJ_ATTR, + PROP_ATTR_WITH_EXCEPTION, + PROP_ATTR_WITH_SETTER_EXCEPTION, + PROP_ATTR_WITH_GETTER_EXCEPTION, + PROP_CUSTOM_ATTR, + PROP_SCRIPT_STRING_ATTR, +}; + + +static void webkit_dom_test_obj_finalize(GObject* object) +{ + WebKitDOMObject* dom_object = WEBKIT_DOM_OBJECT(object); + + if (dom_object->coreObject != NULL) { + WebCore::TestObj* coreObject = static_cast<WebCore::TestObj *>(dom_object->coreObject); + + WebKit::DOMObjectCache::forget(coreObject); + coreObject->deref(); + + dom_object->coreObject = NULL; + } + + G_OBJECT_CLASS(webkit_dom_test_obj_parent_class)->finalize(object); +} + +static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec) +{ + WebKitDOMTestObj *self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_INT_ATTR: + { + coreSelf->setIntAttr((g_value_get_long(value)) ); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + coreSelf->setUnsignedLongLongAttr((g_value_get_uint64(value)) ); + break; + } + case PROP_STRING_ATTR: + { + coreSelf->setStringAttr(WebCore::String::fromUTF8(g_value_get_string(value)) ); + break; + } + case PROP_ATTR_WITH_EXCEPTION: + { + coreSelf->setAttrWithException((g_value_get_long(value)) ); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + coreSelf->setAttrWithSetterException((g_value_get_long(value)) ); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + coreSelf->setAttrWithGetterException((g_value_get_long(value)) ); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) +{ + WebKitDOMTestObj* self = WEBKIT_DOM_TEST_OBJ(object); + WebCore::TestObj* coreSelf = WebKit::core(self); + switch (prop_id) { + case PROP_READ_ONLY_INT_ATTR: + { + g_value_set_long(value, coreSelf->readOnlyIntAttr()); + break; + } + case PROP_READ_ONLY_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->readOnlyStringAttr())); + break; + } + case PROP_READ_ONLY_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->readOnlyTestObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_INT_ATTR: + { + g_value_set_long(value, coreSelf->intAttr()); + break; + } + case PROP_LONG_LONG_ATTR: + { + g_value_set_int64(value, coreSelf->longLongAttr()); + break; + } + case PROP_UNSIGNED_LONG_LONG_ATTR: + { + g_value_set_uint64(value, coreSelf->unsignedLongLongAttr()); + break; + } + case PROP_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->stringAttr())); + break; + } + case PROP_TEST_OBJ_ATTR: + { + RefPtr<WebCore::TestObj> ptr = coreSelf->testObjAttr(); + g_value_set_object(value, WebKit::kit(ptr.get())); + break; + } + case PROP_ATTR_WITH_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithException()); + break; + } + case PROP_ATTR_WITH_SETTER_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithSetterException()); + break; + } + case PROP_ATTR_WITH_GETTER_EXCEPTION: + { + g_value_set_long(value, coreSelf->attrWithGetterException()); + break; + } + case PROP_SCRIPT_STRING_ATTR: + { + g_value_take_string(value, convertToUTF8String(coreSelf->scriptStringAttr())); + break; + } + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } +} + + +static void webkit_dom_test_obj_class_init(WebKitDOMTestObjClass* requestClass) +{ + GObjectClass *gobjectClass = G_OBJECT_CLASS(requestClass); + gobjectClass->finalize = webkit_dom_test_obj_finalize; + gobjectClass->set_property = webkit_dom_test_obj_set_property; + gobjectClass->get_property = webkit_dom_test_obj_get_property; + + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_INT_ATTR, + g_param_spec_long("read-only-int-attr", /* name */ + "test_obj_read-only-int-attr", /* short description */ + "read-only glong TestObj.read-only-int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_STRING_ATTR, + g_param_spec_string("read-only-string-attr", /* name */ + "test_obj_read-only-string-attr", /* short description */ + "read-only gchar* TestObj.read-only-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_READ_ONLY_TEST_OBJ_ATTR, + g_param_spec_object("read-only-test-obj-attr", /* name */ + "test_obj_read-only-test-obj-attr", /* short description */ + "read-only WebKitDOMTestObj* TestObj.read-only-test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READABLE)); + g_object_class_install_property(gobjectClass, + PROP_INT_ATTR, + g_param_spec_long("int-attr", /* name */ + "test_obj_int-attr", /* short description */ + "read-write glong TestObj.int-attr", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_LONG_LONG_ATTR, + g_param_spec_int64("long-long-attr", /* name */ + "test_obj_long-long-attr", /* short description */ + "read-write gint64 TestObj.long-long-attr", /* longer - could do with some extra doc stuff here */ + G_MININT64, /* min */ +G_MAXINT64, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_UNSIGNED_LONG_LONG_ATTR, + g_param_spec_uint64("unsigned-long-long-attr", /* name */ + "test_obj_unsigned-long-long-attr", /* short description */ + "read-write guint64 TestObj.unsigned-long-long-attr", /* longer - could do with some extra doc stuff here */ + 0, /* min */ +G_MAXUINT64, /* min */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_STRING_ATTR, + g_param_spec_string("string-attr", /* name */ + "test_obj_string-attr", /* short description */ + "read-write gchar* TestObj.string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_TEST_OBJ_ATTR, + g_param_spec_object("test-obj-attr", /* name */ + "test_obj_test-obj-attr", /* short description */ + "read-write WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */ + WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_EXCEPTION, + g_param_spec_long("attr-with-exception", /* name */ + "test_obj_attr-with-exception", /* short description */ + "read-write glong TestObj.attr-with-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_SETTER_EXCEPTION, + g_param_spec_long("attr-with-setter-exception", /* name */ + "test_obj_attr-with-setter-exception", /* short description */ + "read-write glong TestObj.attr-with-setter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_ATTR_WITH_GETTER_EXCEPTION, + g_param_spec_long("attr-with-getter-exception", /* name */ + "test_obj_attr-with-getter-exception", /* short description */ + "read-write glong TestObj.attr-with-getter-exception", /* longer - could do with some extra doc stuff here */ + G_MINLONG, /* min */ +G_MAXLONG, /* max */ +0, /* default */ + WEBKIT_PARAM_READWRITE)); + g_object_class_install_property(gobjectClass, + PROP_SCRIPT_STRING_ATTR, + g_param_spec_string("script-string-attr", /* name */ + "test_obj_script-string-attr", /* short description */ + "read-only gchar* TestObj.script-string-attr", /* longer - could do with some extra doc stuff here */ + "", /* default */ + WEBKIT_PARAM_READABLE)); + + + +} + +static void webkit_dom_test_obj_init(WebKitDOMTestObj* request) +{ +} + diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h new file mode 100644 index 0000000..f8ad9c4 --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -0,0 +1,177 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WebKitDOMTestObj_h +#define WebKitDOMTestObj_h + +#include "webkit/webkitdomdefines.h" +#include <glib-object.h> +#include <webkit/webkitdefines.h> +#include "webkit/WebKitDOMObject.h" + + +G_BEGIN_DECLS +#define WEBKIT_TYPE_DOM_TEST_OBJ (webkit_dom_test_obj_get_type()) +#define WEBKIT_DOM_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObj)) +#define WEBKIT_DOM_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass) +#define WEBKIT_DOM_IS_TEST_OBJ(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_IS_TEST_OBJ_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DOM_TEST_OBJ)) +#define WEBKIT_DOM_TEST_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DOM_TEST_OBJ, WebKitDOMTestObjClass)) + +struct _WebKitDOMTestObj { + WebKitDOMObject parent_instance; +}; + +struct _WebKitDOMTestObjClass { + WebKitDOMObjectClass parent_class; +}; + +WEBKIT_API GType +webkit_dom_test_obj_get_type (void); + +WEBKIT_API void +webkit_dom_test_obj_void_method (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_void_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API glong +webkit_dom_test_obj_int_method (WebKitDOMTestObj *self); + +WEBKIT_API glong +webkit_dom_test_obj_int_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API void +webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg); + +WEBKIT_API void +webkit_dom_test_obj_method_with_exception (WebKitDOMTestObj *self, GError **error); + + +/* TODO: event function webkit_dom_test_obj_add_event_listener */ + + +/* TODO: event function webkit_dom_test_obj_remove_event_listener */ + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_arg (WebKitDOMTestObj *self, glong int_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_optional_arg (WebKitDOMTestObj *self, glong int_arg, glong optional_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture (WebKitDOMTestObj *self, glong int_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_dynamic_frame_and_user_gesture_asad (WebKitDOMTestObj *self, glong int_arg, glong optional_arg); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_with_script_state_void_exception (WebKitDOMTestObj *self, GError **error); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_with_script_state_obj_exception (WebKitDOMTestObj *self, GError **error); + +WEBKIT_API void +webkit_dom_test_obj_method_with_optional_arg (WebKitDOMTestObj *self, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_optional_arg (WebKitDOMTestObj *self, glong non_opt, glong opt); + +WEBKIT_API void +webkit_dom_test_obj_method_with_non_optional_arg_and_two_optional_args (WebKitDOMTestObj *self, glong non_opt, glong opt1, glong opt2); + +WEBKIT_API glong +webkit_dom_test_obj_get_read_only_int_attr (WebKitDOMTestObj *self); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_read_only_string_attr (WebKitDOMTestObj *self); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_read_only_test_obj_attr (WebKitDOMTestObj *self); + +WEBKIT_API glong +webkit_dom_test_obj_get_int_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_int_attr (WebKitDOMTestObj *self, glong value); + +WEBKIT_API gint64 +webkit_dom_test_obj_get_long_long_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_long_long_attr (WebKitDOMTestObj *self, gint64 value); + +WEBKIT_API guint64 +webkit_dom_test_obj_get_unsigned_long_long_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_unsigned_long_long_attr (WebKitDOMTestObj *self, guint64 value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_string_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_string_attr (WebKitDOMTestObj *self, gchar* value); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_get_test_obj_attr (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_test_obj_attr (WebKitDOMTestObj *self, WebKitDOMTestObj* value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API glong +webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self); + +WEBKIT_API void +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value); + +WEBKIT_API gchar* +webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self); + +G_END_DECLS + +#endif /* WebKitDOMTestObj_h */ diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h new file mode 100644 index 0000000..78cd87f --- /dev/null +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObjPrivate.h @@ -0,0 +1,39 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef WEB_KIT_DOM_TEST_OBJ_PRIVATE_H +#define WEB_KIT_DOM_TEST_OBJ_PRIVATE_H + +#include <glib-object.h> +#include <webkit/WebKitDOMObject.h> +#include "TestObj.h" +namespace WebKit { + WebKitDOMTestObj * + wrapTestObj(WebCore::TestObj *coreObject); + + WebCore::TestObj * + core(WebKitDOMTestObj *request); + + gpointer + kit(WebCore::TestObj* node); + +} // namespace WebKit + +#endif /* WEB_KIT_DOM_TEST_OBJ_PRIVATE_H */ diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp new file mode 100644 index 0000000..2d0cfae --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -0,0 +1,100 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" + +#if ENABLE(DATABASE) + +#include "JSTestCallback.h" + +#include "JSClass1.h" +#include "JSClass2.h" +#include "ScriptExecutionContext.h" +#include <runtime/JSLock.h> +#include <wtf/MainThread.h> + +using namespace JSC; + +namespace WebCore { + +JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) + : m_data(new JSCallbackData(callback, globalObject)) + , m_isolatedWorld(globalObject->world()) +{ +} + +JSTestCallback::~JSTestCallback() +{ + callOnMainThread(JSCallbackData::deleteData, m_data); +#ifndef NDEBUG + m_data = 0; +#endif +} + +// Functions + +bool JSTestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +{ + ASSERT(m_data); + ASSERT(context); + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); + if (!globalObject) + return true; + + ExecState* exec = globalObject->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class1Param)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +bool JSTestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +{ + ASSERT(m_data); + ASSERT(context); + + RefPtr<JSTestCallback> protect(this); + + JSLock lock(SilenceAssertionsOnly); + + JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get()); + if (!globalObject) + return true; + + ExecState* exec = globalObject->globalExec(); + MarkedArgumentBuffer args; + args.append(toJS(exec, class2Param)); + args.append(toJS(exec, strArg)); + + bool raisedException = false; + m_data->invokeCallback(args, &raisedException); + return !raisedException; +} + +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h new file mode 100644 index 0000000..6e8f083 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -0,0 +1,58 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestCallback_h +#define JSTestCallback_h + +#if ENABLE(DATABASE) + +#include "JSCallbackData.h" +#include "TestCallback.h" +#include <wtf/Forward.h> + +namespace WebCore { + +class JSTestCallback : public TestCallback { +public: + static PassRefPtr<JSTestCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) + { + return adoptRef(new JSTestCallback(callback, globalObject)); + } + + virtual ~JSTestCallback(); + + // Functions + virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); + virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); + virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + +private: + JSTestCallback(JSC::JSObject* callback, JSDOMGlobalObject*); + + JSCallbackData* m_data; + RefPtr<DOMWrapperWorld> m_isolatedWorld; +}; + +} // namespace WebCore + +#endif // ENABLE(DATABASE) + +#endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp new file mode 100644 index 0000000..8855481 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -0,0 +1,193 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSTestInterface.h" + +#include "TestInterface.h" +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestInterface); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceTableValues[2] = +{ + { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfaceTableValues, 0 }; +#else + { 2, 1, JSTestInterfaceTableValues, 0 }; +#endif + +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfaceConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfaceConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfaceConstructorTableValues, 0 }; +#else + { 1, 0, JSTestInterfaceConstructorTableValues, 0 }; +#endif + +class JSTestInterfaceConstructor : public DOMConstructorObject { +public: + JSTestInterfaceConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestInterfaceConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSTestInterfacePrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr<Structure> createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; + static JSObject* constructTestInterface(ExecState* exec, JSObject* constructor, const ArgList&) + { + ScriptExecutionContext* context = static_cast<JSTestInterfaceConstructor*>(constructor)->scriptExecutionContext(); + if (!context) + return throwError(exec, ReferenceError); + return asObject(toJS(exec, static_cast<JSTestInterfaceConstructor*>(constructor)->globalObject(), TestInterface::create(context))); + } + virtual ConstructType getConstructData(ConstructData& constructData) + { + constructData.native.function = constructTestInterface; + return ConstructTypeHost; + } +}; + +const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", 0, &JSTestInterfaceConstructorTable, 0 }; + +bool JSTestInterfaceConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, slot); +} + +bool JSTestInterfaceConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterfaceConstructor, DOMObject>(exec, &JSTestInterfaceConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestInterfacePrototypeTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestInterfacePrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestInterfacePrototypeTableValues, 0 }; +#else + { 1, 0, JSTestInterfacePrototypeTableValues, 0 }; +#endif + +const ClassInfo JSTestInterfacePrototype::s_info = { "TestInterfacePrototype", 0, &JSTestInterfacePrototypeTable, 0 }; + +JSObject* JSTestInterfacePrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestInterface>(exec, globalObject); +} + +const ClassInfo JSTestInterface::s_info = { "TestInterface", 0, &JSTestInterfaceTable, 0 }; + +JSTestInterface::JSTestInterface(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestInterface> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestInterface::~JSTestInterface() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestInterface::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestInterfacePrototype(JSTestInterfacePrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestInterface::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, slot); +} + +bool JSTestInterface::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestInterface, Base>(exec, &JSTestInterfaceTable, this, propertyName, descriptor); +} + +JSValue jsTestInterfaceConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestInterface* domObject = static_cast<JSTestInterface*>(asObject(slotBase)); + return JSTestInterface::getConstructor(exec, domObject->globalObject()); +} +JSValue JSTestInterface::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestInterfaceConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestInterface* object) +{ + return getDOMObjectWrapper<JSTestInterface>(exec, globalObject, object); +} +TestInterface* toTestInterface(JSC::JSValue value) +{ + return value.inherits(&JSTestInterface::s_info) ? static_cast<JSTestInterface*>(asObject(value))->impl() : 0; +} + +} diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.h b/WebCore/bindings/scripts/test/JS/JSTestInterface.h new file mode 100644 index 0000000..c076dbd --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.h @@ -0,0 +1,81 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestInterface_h +#define JSTestInterface_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestInterface; + +class JSTestInterface : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestInterface(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestInterface>); + virtual ~JSTestInterface(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + TestInterface* impl() const { return m_impl.get(); } + +private: + RefPtr<TestInterface> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestInterface*); +TestInterface* toTestInterface(JSC::JSValue); + +class JSTestInterfacePrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestInterfacePrototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = Base::StructureFlags; +}; + +// Attributes + +JSC::JSValue jsTestInterfaceConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp new file mode 100644 index 0000000..da99de2 --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -0,0 +1,813 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "JSTestObj.h" + +#include "JSEventListener.h" +#include "JSTestObj.h" +#include "JSlog.h" +#include "KURL.h" +#include "ScriptCallStack.h" +#include "SerializedScriptValue.h" +#include "TestObj.h" +#include <runtime/Error.h> +#include <runtime/JSNumberCell.h> +#include <runtime/JSString.h> +#include <wtf/GetPtr.h> + +using namespace JSC; + +namespace WebCore { + +ASSERT_CLASS_FITS_IN_CELL(JSTestObj); + +/* Hash table */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjTableValues[15] = +{ + { "readOnlyIntAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyTestObjAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntAttr), (intptr_t)setJSTestObjIntAttr THUNK_GENERATOR(0) }, + { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongAttr), (intptr_t)setJSTestObjLongLongAttr THUNK_GENERATOR(0) }, + { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) }, + { "stringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjStringAttr), (intptr_t)setJSTestObjStringAttr THUNK_GENERATOR(0) }, + { "testObjAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjTestObjAttr), (intptr_t)setJSTestObjTestObjAttr THUNK_GENERATOR(0) }, + { "attrWithException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithException), (intptr_t)setJSTestObjAttrWithException THUNK_GENERATOR(0) }, + { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, + { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) }, + { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) }, + { "scriptStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 127, JSTestObjTableValues, 0 }; +#else + { 34, 31, JSTestObjTableValues, 0 }; +#endif + +/* Hash table for constructor */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjConstructorTableValues[1] = +{ + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjConstructorTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 0, JSTestObjConstructorTableValues, 0 }; +#else + { 1, 0, JSTestObjConstructorTableValues, 0 }; +#endif + +class JSTestObjConstructor : public DOMConstructorObject { +public: + JSTestObjConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSTestObjConstructor::createStructure(globalObject->objectPrototype()), globalObject) + { + putDirect(exec->propertyNames().prototype, JSTestObjPrototype::self(exec, globalObject), None); + } + virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&); + virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&); + virtual const ClassInfo* classInfo() const { return &s_info; } + static const ClassInfo s_info; + + static PassRefPtr<Structure> createStructure(JSValue proto) + { + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount); + } + +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | DOMConstructorObject::StructureFlags; +}; + +const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", 0, &JSTestObjConstructorTable, 0 }; + +bool JSTestObjConstructor::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, slot); +} + +bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObjConstructor, DOMObject>(exec, &JSTestObjConstructorTable, this, propertyName, descriptor); +} + +/* Hash table for prototype */ +#if ENABLE(JIT) +#define THUNK_GENERATOR(generator) , generator +#else +#define THUNK_GENERATOR(generator) +#endif + +static const HashTableValue JSTestObjPrototypeTableValues[26] = +{ + { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "intMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "objMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "objMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "serializedValue", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "customArgsAndException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, + { "addEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "removeEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "withDynamicFrame", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGesture", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGestureASAD", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { 0, 0, 0, 0 THUNK_GENERATOR(0) } +}; + +#undef THUNK_GENERATOR +static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = +#if ENABLE(PERFECT_HASH_SIZE) + { 8191, JSTestObjPrototypeTableValues, 0 }; +#else + { 67, 63, JSTestObjPrototypeTableValues, 0 }; +#endif + +const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; + +JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMPrototype<JSTestObj>(exec, globalObject); +} + +bool JSTestObjPrototype::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticFunctionSlot<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, slot); +} + +bool JSTestObjPrototype::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticFunctionDescriptor<JSObject>(exec, &JSTestObjPrototypeTable, this, propertyName, descriptor); +} + +const ClassInfo JSTestObj::s_info = { "TestObj", 0, &JSTestObjTable, 0 }; + +JSTestObj::JSTestObj(NonNullPassRefPtr<Structure> structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl) + : DOMObjectWithGlobalPointer(structure, globalObject) + , m_impl(impl) +{ +} + +JSTestObj::~JSTestObj() +{ + forgetDOMObject(this, impl()); +} + +JSObject* JSTestObj::createPrototype(ExecState* exec, JSGlobalObject* globalObject) +{ + return new (exec) JSTestObjPrototype(JSTestObjPrototype::createStructure(globalObject->objectPrototype())); +} + +bool JSTestObj::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot) +{ + return getStaticValueSlot<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, slot); +} + +bool JSTestObj::getOwnPropertyDescriptor(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor) +{ + return getStaticValueDescriptor<JSTestObj, Base>(exec, &JSTestObjTable, this, propertyName, descriptor); +} + +JSValue jsTestObjReadOnlyIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->readOnlyIntAttr()); + return result; +} + +JSValue jsTestObjReadOnlyStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->readOnlyStringAttr()); + return result; +} + +JSValue jsTestObjReadOnlyTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->readOnlyTestObjAttr())); + return result; +} + +JSValue jsTestObjIntAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->intAttr()); + return result; +} + +JSValue jsTestObjLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->longLongAttr()); + return result; +} + +JSValue jsTestObjUnsignedLongLongAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->unsignedLongLongAttr()); + return result; +} + +JSValue jsTestObjStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsString(exec, imp->stringAttr()); + return result; +} + +JSValue jsTestObjTestObjAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->testObjAttr())); + return result; +} + +JSValue jsTestObjAttrWithException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithException()); + return result; +} + +JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithSetterException()); + return result; +} + +JSValue jsTestObjAttrWithGetterException(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsNumber(exec, imp->attrWithGetterException()); + return result; +} + +JSValue jsTestObjCustomAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + return castedThis->customAttr(exec); +} + +JSValue jsTestObjScriptStringAttr(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); + UNUSED_PARAM(exec); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue result = jsOwnedStringOrNull(exec, imp->scriptStringAttr()); + return result; +} + +JSValue jsTestObjConstructor(ExecState* exec, JSValue slotBase, const Identifier&) +{ + JSTestObj* domObject = static_cast<JSTestObj*>(asObject(slotBase)); + return JSTestObj::getConstructor(exec, domObject->globalObject()); +} +void JSTestObj::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) +{ + lookupPut<JSTestObj, Base>(exec, propertyName, value, &JSTestObjTable, this, slot); +} + +void setJSTestObjIntAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setIntAttr(value.toInt32(exec)); +} + +void setJSTestObjLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setLongLongAttr(static_cast<long long>(value.toInteger(exec))); +} + +void setJSTestObjUnsignedLongLongAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setUnsignedLongLongAttr(static_cast<unsigned long long>(value.toInteger(exec))); +} + +void setJSTestObjStringAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setStringAttr(ustringToString(value.toString(exec))); +} + +void setJSTestObjTestObjAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setTestObjAttr(toTestObj(value)); +} + +void setJSTestObjAttrWithException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithException(value.toInt32(exec)); +} + +void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithSetterException(value.toInt32(exec)); +} + +void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) +{ + JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + imp->setAttrWithGetterException(value.toInt32(exec)); +} + +void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) +{ + static_cast<JSTestObj*>(thisObject)->setCustomAttr(exec, value); +} + +JSValue JSTestObj::getConstructor(ExecState* exec, JSGlobalObject* globalObject) +{ + return getDOMConstructor<JSTestObjConstructor>(exec, static_cast<JSDOMGlobalObject*>(globalObject)); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->voidMethod(); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + imp->voidMethodWithArgs(intArg, strArg, objArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = jsNumber(exec, imp->intMethod()); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + + JSC::JSValue result = jsNumber(exec, imp->intMethodWithArgs(intArg, strArg, objArg)); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethod())); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + const String& strArg = ustringToString(args.at(1).toString(exec)); + TestObj* objArg = toTestObj(args.at(2)); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->objMethodWithArgs(intArg, strArg, objArg))); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(exec, args.at(0)); + + imp->serializedValue(serializedArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->methodWithException(ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return castedThis->customMethod(exec, args); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + return castedThis->customMethodWithArgs(exec, args); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + ScriptCallStack callStack(exec, args, 1); + log* intArg = tolog(args.at(0)); + + imp->customArgsAndException(intArg, &callStack, ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->addEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)), args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + JSValue listener = args.at(1); + if (!listener.isObject()) + return jsUndefined(); + imp->removeEventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec)).get(), args.at(2).toBoolean(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + + imp->withDynamicFrame(dynamicFrame); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + imp->withDynamicFrameAndArg(dynamicFrame, intArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 3) { + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg); + return jsUndefined(); + } + + int optionalArg = args.at(2).toInt32(exec); + + imp->withDynamicFrameAndOptionalArg(dynamicFrame, intArg, optionalArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + imp->withDynamicFrameAndUserGesture(dynamicFrame, intArg, processingUserGesture(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + Frame* dynamicFrame = toDynamicFrame(exec); + if (!dynamicFrame) + return jsUndefined(); + int intArg = args.at(1).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 3) { + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg); + return jsUndefined(); + } + + int optionalArg = args.at(2).toInt32(exec); + + imp->withDynamicFrameAndUserGestureASAD(dynamicFrame, intArg, optionalArg, processingUserGesture(exec)); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + imp->withScriptStateVoid(exec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObj(exec))); + if (exec->hadException()) + return jsUndefined(); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + imp->withScriptStateVoidException(exec, ec); + setDOMException(exec, ec); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + ExceptionCode ec = 0; + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->withScriptStateObjException(exec, ec))); + setDOMException(exec, ec); + if (exec->hadException()) + return jsUndefined(); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + + int argsCount = args.size(); + if (argsCount < 1) { + imp->methodWithOptionalArg(); + return jsUndefined(); + } + + int opt = args.at(0).toInt32(exec); + + imp->methodWithOptionalArg(opt); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = args.at(0).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 2) { + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt); + return jsUndefined(); + } + + int opt = args.at(1).toInt32(exec); + + imp->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int nonOpt = args.at(0).toInt32(exec); + + int argsCount = args.size(); + if (argsCount < 2) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt); + return jsUndefined(); + } + + int opt1 = args.at(1).toInt32(exec); + if (argsCount < 3) { + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1); + return jsUndefined(); + } + + int opt2 = args.at(2).toInt32(exec); + + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return jsUndefined(); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object) +{ + return getDOMObjectWrapper<JSTestObj>(exec, globalObject, object); +} +TestObj* toTestObj(JSC::JSValue value) +{ + return value.inherits(&JSTestObj::s_info) ? static_cast<JSTestObj*>(asObject(value))->impl() : 0; +} + +} diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.h b/WebCore/bindings/scripts/test/JS/JSTestObj.h new file mode 100644 index 0000000..f726efb --- /dev/null +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -0,0 +1,141 @@ +/* + This file is part of the WebKit 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., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef JSTestObj_h +#define JSTestObj_h + +#include "JSDOMBinding.h" +#include <runtime/JSGlobalObject.h> +#include <runtime/ObjectPrototype.h> + +namespace WebCore { + +class TestObj; + +class JSTestObj : public DOMObjectWithGlobalPointer { + typedef DOMObjectWithGlobalPointer Base; +public: + JSTestObj(NonNullPassRefPtr<JSC::Structure>, JSDOMGlobalObject*, PassRefPtr<TestObj>); + virtual ~JSTestObj(); + static JSC::JSObject* createPrototype(JSC::ExecState*, JSC::JSGlobalObject*); + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&); + virtual void put(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSValue, JSC::PutPropertySlot&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + + static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*); + + // Custom attributes + JSC::JSValue customAttr(JSC::ExecState*) const; + void setCustomAttr(JSC::ExecState*, JSC::JSValue); + + // Custom functions + JSC::JSValue customMethod(JSC::ExecState*, const JSC::ArgList&); + JSC::JSValue customMethodWithArgs(JSC::ExecState*, const JSC::ArgList&); + TestObj* impl() const { return m_impl.get(); } + +private: + RefPtr<TestObj> m_impl; +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestObj*); +TestObj* toTestObj(JSC::JSValue); + +class JSTestObjPrototype : public JSC::JSObject { + typedef JSC::JSObject Base; +public: + static JSC::JSObject* self(JSC::ExecState*, JSC::JSGlobalObject*); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + static const JSC::ClassInfo s_info; + virtual bool getOwnPropertySlot(JSC::ExecState*, const JSC::Identifier&, JSC::PropertySlot&); + virtual bool getOwnPropertyDescriptor(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&); + static PassRefPtr<JSC::Structure> createStructure(JSC::JSValue prototype) + { + return JSC::Structure::create(prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount); + } + JSTestObjPrototype(NonNullPassRefPtr<JSC::Structure> structure) : JSC::JSObject(structure) { } +protected: + static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | Base::StructureFlags; +}; + +// Functions + +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVoidMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomArgsAndException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAddEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionRemoveEventListener(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrame(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoid(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObj(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateVoidException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +// Attributes + +JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjReadOnlyTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjIntAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjUnsignedLongLongAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjTestObjAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjTestObjAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithSetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjAttrWithGetterException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjCustomAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +void setJSTestObjCustomAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue); +JSC::JSValue jsTestObjScriptStringAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); +JSC::JSValue jsTestObjConstructor(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h new file mode 100644 index 0000000..1213c6f --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMClass1; +@class DOMClass2; +@class DOMClass3; +@class DOMClass5; +@class DOMClass6; +@class NSString; + +@interface DOMTestCallback : DOMObject +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param; +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg; +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param; +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param; +@end + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm new file mode 100644 index 0000000..5201a91 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallback.mm @@ -0,0 +1,122 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" + +#if ENABLE(DATABASE) + +#import "DOMInternal.h" + +#import "DOMTestCallback.h" + +#import "Class1.h" +#import "Class2.h" +#import "Class3.h" +#import "Class5.h" +#import "Class6.h" +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMClass1Internal.h" +#import "DOMClass2Internal.h" +#import "DOMClass3Internal.h" +#import "DOMClass5Internal.h" +#import "DOMClass6Internal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestCallbackInternal.h" +#import "ExceptionHandlers.h" +#import "KURL.h" +#import "TestCallback.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestCallback*>(_internal) + +@implementation DOMTestCallback + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestCallback class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (BOOL)callbackWithClass1Param:(DOMClass1 *)class1Param +{ + return IMPL->callbackWithClass1Param(core(class1Param)); +} + +- (BOOL)callbackWithClass2Param:(DOMClass2 *)class2Param strArg:(NSString *)strArg +{ + return IMPL->callbackWithClass2Param(core(class2Param), strArg); +} + +- (int)callbackWithNonBoolReturnType:(DOMClass3 *)class3Param +{ + return IMPL->callbackWithNonBoolReturnType(core(class3Param)); +} + +- (int)customCallback:(DOMClass5 *)class5Param class6Param:(DOMClass6 *)class6Param +{ + return IMPL->customCallback(core(class5Param), core(class6Param)); +} + +@end + +WebCore::TestCallback* core(DOMTestCallback *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestCallback*>(wrapper->_internal) : 0; +} + +DOMTestCallback *kit(WebCore::TestCallback* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestCallback *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestCallback *wrapper = [[DOMTestCallback alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h new file mode 100644 index 0000000..d8ea940 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestCallbackInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestCallback.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestCallback; +} + +WebCore::TestCallback* core(DOMTestCallback *); +DOMTestCallback *kit(WebCore::TestCallback*); + +#endif diff --git a/WebCore/bindings/js/JSDocumentFragmentCustom.cpp b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h index 7bc7d68..db7be28 100644 --- a/WebCore/bindings/js/JSDocumentFragmentCustom.cpp +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.h @@ -1,5 +1,6 @@ /* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,10 +11,10 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR @@ -23,18 +24,11 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "config.h" -#include "JSDocumentFragment.h" +#import <WebCore/DOMObject.h> -#include "DocumentFragment.h" -#include "Element.h" -#include "ExceptionCode.h" -#include "JSElement.h" -#include "JSNodeList.h" -#include "NodeList.h" +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST -using namespace JSC; +@interface DOMTestInterface : DOMObject +@end -namespace WebCore { - -} // namespace WebCore +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm new file mode 100644 index 0000000..a88b366 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterface.mm @@ -0,0 +1,86 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestInterface.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestInterfaceInternal.h" +#import "ExceptionHandlers.h" +#import "TestInterface.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestInterface*>(_internal) + +@implementation DOMTestInterface + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestInterface class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +@end + +WebCore::TestInterface* core(DOMTestInterface *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestInterface*>(wrapper->_internal) : 0; +} + +DOMTestInterface *kit(WebCore::TestInterface* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestInterface *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestInterface *wrapper = [[DOMTestInterface alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h new file mode 100644 index 0000000..fef60a3 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestInterfaceInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestInterface.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestInterface; +} + +WebCore::TestInterface* core(DOMTestInterface *); +DOMTestInterface *kit(WebCore::TestInterface*); + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h new file mode 100644 index 0000000..dd9d2ee --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMObject.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +@class DOMTestObj; +@class DOMlog; +@class NSString; +@protocol DOMEventListener; + +@interface DOMTestObj : DOMObject +- (int)readOnlyIntAttr; +- (NSString *)readOnlyStringAttr; +- (DOMTestObj *)readOnlyTestObjAttr; +- (int)intAttr; +- (void)setIntAttr:(int)newIntAttr; +- (long long)longLongAttr; +- (void)setLongLongAttr:(long long)newLongLongAttr; +- (unsigned long long)unsignedLongLongAttr; +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr; +- (NSString *)stringAttr; +- (void)setStringAttr:(NSString *)newStringAttr; +- (DOMTestObj *)testObjAttr; +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr; +- (int)attrWithException; +- (void)setAttrWithException:(int)newAttrWithException; +- (int)attrWithSetterException; +- (void)setAttrWithSetterException:(int)newAttrWithSetterException; +- (int)attrWithGetterException; +- (void)setAttrWithGetterException:(int)newAttrWithGetterException; +- (int)customAttr; +- (void)setCustomAttr:(int)newCustomAttr; +- (NSString *)scriptStringAttr; +- (void)voidMethod; +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (int)intMethod; +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)objMethod; +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)serializedValue:(NSString *)serializedArg; +- (void)methodWithException; +- (void)customMethod; +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (void)customArgsAndException:(DOMlog *)intArg; +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture; +- (void)withDynamicFrame; +- (void)withDynamicFrameAndArg:(int)intArg; +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg; +- (void)withDynamicFrameAndUserGesture:(int)intArg; +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg; +- (void)withScriptStateVoid; +- (DOMTestObj *)withScriptStateObj; +- (void)withScriptStateVoidException; +- (DOMTestObj *)withScriptStateObjException; +- (void)methodWithOptionalArg:(int)opt; +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt; +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2; +@end + +#endif diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm new file mode 100644 index 0000000..b964e36 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -0,0 +1,340 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import "config.h" +#import "DOMInternal.h" + +#import "DOMTestObj.h" + +#import "DOMBlobInternal.h" +#import "DOMCSSRuleInternal.h" +#import "DOMCSSValueInternal.h" +#import "DOMEventInternal.h" +#import "DOMNodeInternal.h" +#import "DOMStyleSheetInternal.h" +#import "DOMTestObjInternal.h" +#import "DOMlogInternal.h" +#import "EventListener.h" +#import "ExceptionHandlers.h" +#import "KURL.h" +#import "ObjCEventListener.h" +#import "SerializedScriptValue.h" +#import "TestObj.h" +#import "ThreadCheck.h" +#import "WebCoreObjCExtras.h" +#import "WebScriptObjectPrivate.h" +#import "log.h" +#import <wtf/GetPtr.h> + +#define IMPL reinterpret_cast<WebCore::TestObj*>(_internal) + +@implementation DOMTestObj + +- (void)dealloc +{ + if (WebCoreObjCScheduleDeallocateOnMainThread([DOMTestObj class], self)) + return; + + if (_internal) + IMPL->deref(); + [super dealloc]; +} + +- (void)finalize +{ + if (_internal) + IMPL->deref(); + [super finalize]; +} + +- (int)readOnlyIntAttr +{ + return IMPL->readOnlyIntAttr(); +} + +- (NSString *)readOnlyStringAttr +{ + return IMPL->readOnlyStringAttr(); +} + +- (DOMTestObj *)readOnlyTestObjAttr +{ + return kit(WTF::getPtr(IMPL->readOnlyTestObjAttr())); +} + +- (int)intAttr +{ + return IMPL->intAttr(); +} + +- (void)setIntAttr:(int)newIntAttr +{ + IMPL->setIntAttr(newIntAttr); +} + +- (long long)longLongAttr +{ + return IMPL->longLongAttr(); +} + +- (void)setLongLongAttr:(long long)newLongLongAttr +{ + IMPL->setLongLongAttr(newLongLongAttr); +} + +- (unsigned long long)unsignedLongLongAttr +{ + return IMPL->unsignedLongLongAttr(); +} + +- (void)setUnsignedLongLongAttr:(unsigned long long)newUnsignedLongLongAttr +{ + IMPL->setUnsignedLongLongAttr(newUnsignedLongLongAttr); +} + +- (NSString *)stringAttr +{ + return IMPL->stringAttr(); +} + +- (void)setStringAttr:(NSString *)newStringAttr +{ + IMPL->setStringAttr(newStringAttr); +} + +- (DOMTestObj *)testObjAttr +{ + return kit(WTF::getPtr(IMPL->testObjAttr())); +} + +- (void)setTestObjAttr:(DOMTestObj *)newTestObjAttr +{ + ASSERT(newTestObjAttr); + + IMPL->setTestObjAttr(core(newTestObjAttr)); +} + +- (int)attrWithException +{ + return IMPL->attrWithException(); +} + +- (void)setAttrWithException:(int)newAttrWithException +{ + IMPL->setAttrWithException(newAttrWithException); +} + +- (int)attrWithSetterException +{ + return IMPL->attrWithSetterException(); +} + +- (void)setAttrWithSetterException:(int)newAttrWithSetterException +{ + IMPL->setAttrWithSetterException(newAttrWithSetterException); +} + +- (int)attrWithGetterException +{ + return IMPL->attrWithGetterException(); +} + +- (void)setAttrWithGetterException:(int)newAttrWithGetterException +{ + IMPL->setAttrWithGetterException(newAttrWithGetterException); +} + +- (int)customAttr +{ + return IMPL->customAttr(); +} + +- (void)setCustomAttr:(int)newCustomAttr +{ + IMPL->setCustomAttr(newCustomAttr); +} + +- (NSString *)scriptStringAttr +{ + return IMPL->scriptStringAttr(); +} + +- (void)voidMethod +{ + IMPL->voidMethod(); +} + +- (void)voidMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + IMPL->voidMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (int)intMethod +{ + return IMPL->intMethod(); +} + +- (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + return IMPL->intMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (DOMTestObj *)objMethod +{ + return kit(WTF::getPtr(IMPL->objMethod())); +} + +- (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + return kit(WTF::getPtr(IMPL->objMethodWithArgs(intArg, strArg, core(objArg)))); +} + +- (void)serializedValue:(NSString *)serializedArg +{ + IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); +} + +- (void)methodWithException +{ + WebCore::ExceptionCode ec = 0; + IMPL->methodWithException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)customMethod +{ + IMPL->customMethod(); +} + +- (void)customMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + IMPL->customMethodWithArgs(intArg, strArg, core(objArg)); +} + +- (void)customArgsAndException:(DOMlog *)intArg +{ + WebCore::ExceptionCode ec = 0; + IMPL->customArgsAndException(core(intArg), ec); + WebCore::raiseOnDOMError(ec); +} + +- (void)addEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->addEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)removeEventListener:(NSString *)type listener:(id <DOMEventListener>)listener useCapture:(BOOL)useCapture +{ + RefPtr<WebCore::EventListener> nativeEventListener = WebCore::ObjCEventListener::wrap(listener); + IMPL->removeEventListener(type, WTF::getPtr(nativeEventListener), useCapture); +} + +- (void)withDynamicFrame +{ + IMPL->withDynamicFrame(); +} + +- (void)withDynamicFrameAndArg:(int)intArg +{ + IMPL->withDynamicFrameAndArg(intArg); +} + +- (void)withDynamicFrameAndOptionalArg:(int)intArg optionalArg:(int)optionalArg +{ + IMPL->withDynamicFrameAndOptionalArg(intArg, optionalArg); +} + +- (void)withDynamicFrameAndUserGesture:(int)intArg +{ + IMPL->withDynamicFrameAndUserGesture(intArg); +} + +- (void)withDynamicFrameAndUserGestureASAD:(int)intArg optionalArg:(int)optionalArg +{ + IMPL->withDynamicFrameAndUserGestureASAD(intArg, optionalArg); +} + +- (void)withScriptStateVoid +{ + IMPL->withScriptStateVoid(); +} + +- (DOMTestObj *)withScriptStateObj +{ + return kit(WTF::getPtr(IMPL->withScriptStateObj())); +} + +- (void)withScriptStateVoidException +{ + WebCore::ExceptionCode ec = 0; + IMPL->withScriptStateVoidException(ec); + WebCore::raiseOnDOMError(ec); +} + +- (DOMTestObj *)withScriptStateObjException +{ + WebCore::ExceptionCode ec = 0; + DOMTestObj *result = kit(WTF::getPtr(IMPL->withScriptStateObjException(ec))); + WebCore::raiseOnDOMError(ec); + return result; +} + +- (void)methodWithOptionalArg:(int)opt +{ + IMPL->methodWithOptionalArg(opt); +} + +- (void)methodWithNonOptionalArgAndOptionalArg:(int)nonOpt opt:(int)opt +{ + IMPL->methodWithNonOptionalArgAndOptionalArg(nonOpt, opt); +} + +- (void)methodWithNonOptionalArgAndTwoOptionalArgs:(int)nonOpt opt1:(int)opt1 opt2:(int)opt2 +{ + IMPL->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); +} + +@end + +WebCore::TestObj* core(DOMTestObj *wrapper) +{ + return wrapper ? reinterpret_cast<WebCore::TestObj*>(wrapper->_internal) : 0; +} + +DOMTestObj *kit(WebCore::TestObj* value) +{ + { DOM_ASSERT_MAIN_THREAD(); WebCoreThreadViolationCheckRoundOne(); }; + if (!value) + return nil; + if (DOMTestObj *wrapper = getDOMWrapper(value)) + return [[wrapper retain] autorelease]; + DOMTestObj *wrapper = [[DOMTestObj alloc] _init]; + wrapper->_internal = reinterpret_cast<DOMObjectInternal*>(value); + value->ref(); + addDOMWrapper(wrapper, value); + return [wrapper autorelease]; +} diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h new file mode 100644 index 0000000..c24ea84 --- /dev/null +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObjInternal.h @@ -0,0 +1,38 @@ +/* + * This file is part of the WebKit open source project. + * This file has been generated by generate-bindings.pl. DO NOT MODIFY! + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#import <WebCore/DOMTestObj.h> + +#if WEBKIT_VERSION_MAX_ALLOWED >= WEBKIT_VERSION_LATEST + +namespace WebCore { + class TestObj; +} + +WebCore::TestObj* core(DOMTestObj *); +DOMTestObj *kit(WebCore::TestObj*); + +#endif diff --git a/WebCore/bindings/js/JSCustomSQLStatementCallback.h b/WebCore/bindings/scripts/test/TestCallback.idl index cb7b34d..25db4c6 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementCallback.h +++ b/WebCore/bindings/scripts/test/TestCallback.idl @@ -1,7 +1,7 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2009 Google Inc. All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary formstrArg, with or without * modification, are permitted provided that the following conditions * are met: * @@ -15,7 +15,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES @@ -26,39 +26,16 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSCustomSQLStatementCallback_h -#define JSCustomSQLStatementCallback_h - -#if ENABLE(DATABASE) - -#include "JSCallbackData.h" -#include "SQLStatementCallback.h" -#include <wtf/Forward.h> - -namespace WebCore { - -class SQLResultSet; - -class JSCustomSQLStatementCallback : public SQLStatementCallback { -public: - static PassRefPtr<JSCustomSQLStatementCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - { - return adoptRef(new JSCustomSQLStatementCallback(callback, globalObject)); - } - - virtual ~JSCustomSQLStatementCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLResultSet*, bool& raisedException); - -private: - JSCustomSQLStatementCallback(JSC::JSObject* callback, JSDOMGlobalObject*); - - JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; -}; - +// This IDL file is for testing the bindings code generator with an interface +// that has the "Callback" attribute and for tracking changes in its ouput. +module test { + interface [ + Conditional=DATABASE, + Callback + ] TestCallback { + boolean callbackWithClass1Param(in Class1 class1Param); + boolean callbackWithClass2Param(in Class2 class2Param, in DOMString strArg); + long callbackWithNonBoolReturnType(in Class3 class3Param); + [Custom] long customCallback(in Class5 class5Param, in Class6 class6Param); + }; } - -#endif // ENABLE(DATABASE) - -#endif // JSCustomSQLStatementCallback_h diff --git a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h b/WebCore/bindings/scripts/test/TestInterface.idl index b1b0792..5a8b008 100644 --- a/WebCore/bindings/js/JSCustomSQLStatementErrorCallback.h +++ b/WebCore/bindings/scripts/test/TestInterface.idl @@ -1,7 +1,7 @@ /* - * Copyright (C) 2007 Apple Inc. All rights reserved. + * Copyright (C) 2010 Google Inc. All rights reserved. * - * Redistribution and use in source and binary forms, with or without + * Redistribution and use in source and binary formstrArg, with or without * modification, are permitted provided that the following conditions * are met: * @@ -15,7 +15,7 @@ * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * EXPRESS OR IMPLIED WARRANTIEstrArg, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES @@ -26,40 +26,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSCustomSQLStatementErrorCallback_h -#define JSCustomSQLStatementErrorCallback_h - -#if ENABLE(DATABASE) - -#include "JSCallbackData.h" -#include "SQLStatementErrorCallback.h" -#include <wtf/Forward.h> - -namespace WebCore { - -class JSCallbackData; -class SQLError; - -class JSCustomSQLStatementErrorCallback : public SQLStatementErrorCallback { -public: - static PassRefPtr<JSCustomSQLStatementErrorCallback> create(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) - { - return adoptRef(new JSCustomSQLStatementErrorCallback(callback, globalObject)); - } - - virtual ~JSCustomSQLStatementErrorCallback(); - - virtual bool handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLError*); - -private: - JSCustomSQLStatementErrorCallback(JSC::JSObject* callback, JSDOMGlobalObject*); - - JSCallbackData* m_data; - RefPtr<DOMWrapperWorld> m_isolatedWorld; -}; - +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. +module test { + interface [ + CanBeConstructed, + CallWith=ScriptExecutionContext + ] TestInterface { + }; } - -#endif // ENABLE(DATABASE) - -#endif // JSCustomSQLStatementErrorCallback_h diff --git a/WebCore/bindings/v8/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl index 662ac64..b14328d 100644 --- a/WebCore/bindings/v8/test/TestObj.idl +++ b/WebCore/bindings/scripts/test/TestObj.idl @@ -26,8 +26,8 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -// This IDL file is for testing the V8 generator and for tracking changes -// in its ouput. +// This IDL file is for testing the bindings code generator and for tracking +// changes in its ouput. module test { interface TestObj { // Attributes @@ -35,6 +35,8 @@ module test { readonly attribute DOMString readOnlyStringAttr; readonly attribute TestObj readOnlyTestObjAttr; attribute long intAttr; + attribute long long longLongAttr; + attribute unsigned long long unsignedLongLongAttr; attribute DOMString stringAttr; attribute TestObj testObjAttr; @@ -46,6 +48,8 @@ module test { TestObj objMethod(); TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + void serializedValue(in SerializedScriptValue serializedArg); + // Exceptions void methodWithException() raises(DOMException); attribute long attrWithException raises(DOMException); @@ -57,15 +61,43 @@ module test { [Custom] void customMethod(); [Custom] void customMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + [CustomArgumentHandling] void customArgsAndException(in log intArg) + raises(DOMException); + + void addEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + void removeEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); + + // 'CallWith' extended attribute + [CallWith=DynamicFrame] void withDynamicFrame(); + [CallWith=DynamicFrame] void withDynamicFrameAndArg(in long intArg); + [CallWith=DynamicFrame] void withDynamicFrameAndOptionalArg(in long intArg, in [Optional] long optionalArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGesture(in long intArg); + [NeedsUserGestureCheck, CallWith=DynamicFrame] void withDynamicFrameAndUserGestureASAD(in long intArg, in [Optional] long optionalArg); + [CallWith=ScriptState] void withScriptStateVoid(); + [CallWith=ScriptState] TestObj withScriptStateObj(); + [CallWith=ScriptState] void withScriptStateVoidException() + raises(DOMException); + [CallWith=ScriptState] TestObj withScriptStateObjException() + raises(DOMException); + // 'Optional' extended attribute void methodWithOptionalArg(in [Optional] long opt); void methodWithNonOptionalArgAndOptionalArg(in long nonOpt, in [Optional] long opt); void methodWithNonOptionalArgAndTwoOptionalArgs(in long nonOpt, in [Optional] long opt1, in long opt2); + // 'ConvertScriptString' extended attribute + readonly attribute [ConvertScriptString] DOMString scriptStringAttr; + +#ifdef TESTING_V8 // Overloads void overloadedMethod(in TestObj objArg, in DOMString strArg); void overloadedMethod(in TestObj objArg, in [Optional] long intArg); void overloadedMethod(in DOMString strArg); void overloadedMethod(in long intArg); +#endif }; } diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp new file mode 100644 index 0000000..e72330d --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -0,0 +1,92 @@ +/* + This file is part of the WebKit 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. +*/ + +#include "config.h" +#include "V8TestCallback.h" + +#if ENABLE(DATABASE) + +#include "Frame.h" +#include "ScriptExecutionContext.h" +#include "V8Class1.h" +#include "V8Class2.h" +#include "V8CustomVoidCallback.h" +#include "V8DOMString.h" + +namespace WebCore { + +V8TestCallback::V8TestCallback(v8::Local<v8::Object> callback, Frame* frame) + : m_callback(v8::Persistent<v8::Object>::New(callback)) + , m_frame(frame) + , m_worldContext(UseCurrentWorld) +{ +} + +V8TestCallback::~V8TestCallback() +{ + m_callback.Dispose(); +} + +// Functions + +bool V8TestCallback::callbackWithClass1Param(ScriptExecutionContext* context, Class1* class1Param) +{ + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> argv[] = { + toV8(class1Param) + }; + + RefPtr<Frame> protect(m_frame); + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 1, argv, callbackReturnValue); +} + +bool V8TestCallback::callbackWithClass2Param(ScriptExecutionContext* context, Class2* class2Param, const String& strArg) +{ + v8::HandleScope handleScope; + + v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); + if (v8Context.IsEmpty()) + return true; + + v8::Context::Scope scope(v8Context); + + v8::Handle<v8::Value> argv[] = { + toV8(class2Param), + toV8(strArg) + }; + + RefPtr<Frame> protect(m_frame); + + bool callbackReturnValue = false; + return !invokeCallback(m_callback, 2, argv, callbackReturnValue); +} + +} // namespace WebCore + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/V8/V8TestCallback.h b/WebCore/bindings/scripts/test/V8/V8TestCallback.h new file mode 100644 index 0000000..f58f3f0 --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestCallback.h @@ -0,0 +1,63 @@ +/* + This file is part of the WebKit 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. +*/ + +#if ENABLE(DATABASE) + +#ifndef V8TestCallback_h +#define V8TestCallback_h + +#include "TestCallback.h" +#include "WorldContextHandle.h" +#include <v8.h> +#include <wtf/Forward.h> + +namespace WebCore { + +class Frame; + +class V8TestCallback : public TestCallback { +public: + static PassRefPtr<V8TestCallback> create(v8::Local<v8::Value> value, Frame* frame) + { + ASSERT(value->IsObject()); + return adoptRef(new V8TestCallback(value->ToObject(), frame)); + } + + virtual ~V8TestCallback(); + + // Functions + virtual bool callbackWithClass1Param(ScriptExecutionContext*, Class1* class1Param); + virtual bool callbackWithClass2Param(ScriptExecutionContext*, Class2* class2Param, const String& strArg); + COMPILE_ASSERT(false) virtual int callbackWithNonBoolReturnType(ScriptExecutionContext*, Class3* class3Param); + virtual int customCallback(ScriptExecutionContext*, Class5* class5Param, Class6* class6Param); + +private: + V8TestCallback(v8::Local<v8::Object>, Frame*); + + v8::Persistent<v8::Object> m_callback; + RefPtr<Frame> m_frame; + WorldContextHandle m_worldContext; +}; + +} + +#endif // V8TestCallback_h + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp new file mode 100644 index 0000000..f0bfb86 --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp @@ -0,0 +1,115 @@ +/* + This file is part of the WebKit 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. +*/ + +#include "config.h" +#include "V8TestInterface.h" + +#include "RuntimeEnabledFeatures.h" +#include "V8Binding.h" +#include "V8BindingState.h" +#include "V8DOMWrapper.h" +#include "V8IsolatedContext.h" +#include "V8Proxy.h" + +namespace WebCore { + +WrapperTypeInfo V8TestInterface::info = { V8TestInterface::GetTemplate, V8TestInterface::derefObject, 0 }; + +namespace TestInterfaceInternal { + +template <typename T> void V8_USE(T) { } + +} // namespace TestInterfaceInternal + +v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestInterface.Contructor"); + return V8Proxy::constructDOMObjectWithScriptExecutionContext<TestInterface>(args, &info); +} +static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Persistent<v8::FunctionTemplate> desc) +{ + v8::Local<v8::Signature> defaultSignature = configureTemplate(desc, "TestInterface", v8::Persistent<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, + 0, 0, + 0, 0); + desc->SetCallHandler(V8TestInterface::constructorCallback); + + + // Custom toString template + desc->Set(getToStringName(), getToStringTemplate()); + return desc; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetRawTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceRawCache = createRawTemplate(); + return V8TestInterfaceRawCache; +} + +v8::Persistent<v8::FunctionTemplate> V8TestInterface::GetTemplate() +{ + static v8::Persistent<v8::FunctionTemplate> V8TestInterfaceCache = ConfigureV8TestInterfaceTemplate(GetRawTemplate()); + return V8TestInterfaceCache; +} + +TestInterface* V8TestInterface::toNative(v8::Handle<v8::Object> object) +{ + return reinterpret_cast<TestInterface*>(object->GetPointerFromInternalField(v8DOMWrapperObjectIndex)); +} + +bool V8TestInterface::HasInstance(v8::Handle<v8::Value> value) +{ + return GetRawTemplate()->HasInstance(value); +} + + +v8::Handle<v8::Object> V8TestInterface::wrap(TestInterface* impl) +{ + v8::Handle<v8::Object> wrapper; + V8Proxy* proxy = 0; + wrapper = getDOMObjectMap().get(impl); + if (!wrapper.IsEmpty()) + return wrapper; + wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl); + if (wrapper.IsEmpty()) + return wrapper; + + impl->ref(); + getDOMObjectMap().set(impl, v8::Persistent<v8::Object>::New(wrapper)); + return wrapper; +} + +v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface > impl) +{ + return toV8(impl.get()); +} + +v8::Handle<v8::Value> toV8(TestInterface* impl) +{ + if (!impl) + return v8::Null(); + return V8TestInterface::wrap(impl); +} + +void V8TestInterface::derefObject(void* object) +{ + static_cast<TestInterface*>(object)->deref(); +} + +} // namespace WebCore diff --git a/WebCore/bindings/scripts/test/V8/V8TestInterface.h b/WebCore/bindings/scripts/test/V8/V8TestInterface.h new file mode 100644 index 0000000..ce1310e --- /dev/null +++ b/WebCore/bindings/scripts/test/V8/V8TestInterface.h @@ -0,0 +1,50 @@ +/* + This file is part of the WebKit 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 V8TestInterface_h +#define V8TestInterface_h + +#include "StringHash.h" +#include "TestInterface.h" +#include "WrapperTypeInfo.h" +#include <v8.h> +#include <wtf/HashMap.h> + +namespace WebCore { + +class V8TestInterface { + +public: + static bool HasInstance(v8::Handle<v8::Value> value); + static v8::Persistent<v8::FunctionTemplate> GetRawTemplate(); + static v8::Persistent<v8::FunctionTemplate> GetTemplate(); + static TestInterface* toNative(v8::Handle<v8::Object>); + static v8::Handle<v8::Object> wrap(TestInterface*); + static void derefObject(void*); + static WrapperTypeInfo info; + static v8::Handle<v8::Value> constructorCallback(const v8::Arguments& args); + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount + 0; +}; + +v8::Handle<v8::Value> toV8(TestInterface*); +v8::Handle<v8::Value> toV8(PassRefPtr<TestInterface >); +} + +#endif // V8TestInterface_h diff --git a/WebCore/bindings/v8/test/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index d51884e..94dcd5e 100644 --- a/WebCore/bindings/v8/test/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -23,11 +23,14 @@ #include "ExceptionCode.h" #include "RuntimeEnabledFeatures.h" +#include "ScriptCallStack.h" +#include "SerializedScriptValue.h" #include "V8Binding.h" #include "V8BindingState.h" #include "V8DOMWrapper.h" #include "V8IsolatedContext.h" #include "V8Proxy.h" +#include "V8log.h" #include <wtf/GetPtr.h> #include <wtf/RefCounted.h> #include <wtf/RefPtr.h> @@ -84,6 +87,38 @@ static void intAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> v return; } +static v8::Handle<v8::Value> longLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->longLongAttr())); +} + +static void longLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.longLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + long long v = toInt64(value); + imp->setLongLongAttr(WTF::getPtr(v)); + return; +} + +static v8::Handle<v8::Value> unsignedLongLongAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + return v8::Number::New(static_cast<double>(imp->unsignedLongLongAttr())); +} + +static void unsignedLongLongAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.unsignedLongLongAttr._set"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + unsigned long long v = toInt64(value); + imp->setUnsignedLongLongAttr(WTF::getPtr(v)); + return; +} + static v8::Handle<v8::Value> stringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.TestObj.stringAttr._get"); @@ -164,6 +199,13 @@ static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo return; } +static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.TestObj.scriptStringAttr._get"); + TestObj* imp = V8TestObj::toNative(info.Holder()); + v8StringOrNull(exec, imp->scriptStringAttr()); +} + static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.voidMethod"); @@ -217,6 +259,18 @@ static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); } +static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.serializedValue"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + bool serializedArgDidThrow = false; + RefPtr<SerializedScriptValue> serializedArg = SerializedScriptValue::create(args[0], serializedArgDidThrow); + if (serializedArgDidThrow) + return v8::Undefined(); + imp->serializedValue(serializedArg); + return v8::Handle<v8::Value>(); +} + static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.methodWithException"); @@ -233,6 +287,183 @@ static v8::Handle<v8::Value> methodWithExceptionCallback(const v8::Arguments& ar return v8::Handle<v8::Value>(); } +static v8::Handle<v8::Value> customArgsAndExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.customArgsAndException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + OwnPtr<ScriptCallStack> callStack(ScriptCallStack::create(args, 1)); + if (!callStack) + return v8::Undefined(); + log* intArg = V8log::HasInstance(args[0]) ? V8log::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0; + imp->customArgsAndException(intArg, callStack.get(), ec); + if (UNLIKELY(ec)) + goto fail; + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> addEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.addEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate); + if (listener) { + V8TestObj::toNative(args.Holder())->addEventListener(v8ValueToAtomicWebCoreString(args[0]), listener, args[2]->BooleanValue()); + createHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> removeEventListenerCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.removeEventListener()"); + RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly); + if (listener) { + V8TestObj::toNative(args.Holder())->removeEventListener(v8ValueToAtomicWebCoreString(args[0]), listener.get(), args[2]->BooleanValue()); + removeHiddenDependency(args.Holder(), args[1], V8TestObj::eventListenerCacheIndex); + } + return v8::Undefined(); +} + +static v8::Handle<v8::Value> withDynamicFrameCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrame"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrame(enteredFrame); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndOptionalArgCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndOptionalArg"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg); + return v8::Handle<v8::Value>(); + } + int optionalArg = toInt32(args[1]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndOptionalArg(enteredFrame, intArg, optionalArg); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGesture"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGesture(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withDynamicFrameAndUserGestureASADCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withDynamicFrameAndUserGestureASAD"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + int intArg = toInt32(args[0]); + if (args.Length() <= 1) { + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, processingUserGesture()); + return v8::Handle<v8::Value>(); + } + int optionalArg = toInt32(args[1]); + Frame* enteredFrame = V8Proxy::retrieveFrameForEnteredContext(); + if (!enteredFrame) + return v8::Undefined(); + imp->withDynamicFrameAndUserGestureASAD(enteredFrame, intArg, optionalArg, processingUserGesture()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateVoidCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoid"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + imp->withScriptStateVoid(&state); + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObj"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObj(&state); + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); +} + +static v8::Handle<v8::Value> withScriptStateVoidExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateVoidException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + imp->withScriptStateVoidException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return v8::Handle<v8::Value>(); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + +static v8::Handle<v8::Value> withScriptStateObjExceptionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.withScriptStateObjException"); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + EmptyScriptState state; + RefPtr<TestObj> result = imp->withScriptStateObjException(&state, ec); + if (UNLIKELY(ec)) + goto fail; + if (state.hadException()) + return throwError(state.exception()); + return toV8(result.release()); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + static v8::Handle<v8::Value> methodWithOptionalArgCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.methodWithOptionalArg"); @@ -343,6 +574,10 @@ static const BatchedAttribute TestObjAttrs[] = { {"readOnlyTestObjAttr", TestObjInternal::readOnlyTestObjAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'intAttr' (Type: 'attribute' ExtAttr: '') {"intAttr", TestObjInternal::intAttrAttrGetter, TestObjInternal::intAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'longLongAttr' (Type: 'attribute' ExtAttr: '') + {"longLongAttr", TestObjInternal::longLongAttrAttrGetter, TestObjInternal::longLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'unsignedLongLongAttr' (Type: 'attribute' ExtAttr: '') + {"unsignedLongLongAttr", TestObjInternal::unsignedLongLongAttrAttrGetter, TestObjInternal::unsignedLongLongAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'stringAttr' (Type: 'attribute' ExtAttr: '') {"stringAttr", TestObjInternal::stringAttrAttrGetter, TestObjInternal::stringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'testObjAttr' (Type: 'attribute' ExtAttr: '') @@ -355,14 +590,28 @@ static const BatchedAttribute TestObjAttrs[] = { {"attrWithGetterException", TestObjInternal::attrWithGetterExceptionAttrGetter, TestObjInternal::attrWithGetterExceptionAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, // Attribute 'customAttr' (Type: 'attribute' ExtAttr: 'Custom') {"customAttr", V8TestObj::customAttrAccessorGetter, V8TestObj::customAttrAccessorSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, + // Attribute 'scriptStringAttr' (Type: 'readonly attribute' ExtAttr: 'ConvertScriptString') + {"scriptStringAttr", TestObjInternal::scriptStringAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, }; static const BatchedCallback TestObjCallbacks[] = { {"voidMethod", TestObjInternal::voidMethodCallback}, {"intMethod", TestObjInternal::intMethodCallback}, {"objMethod", TestObjInternal::objMethodCallback}, + {"serializedValue", TestObjInternal::serializedValueCallback}, {"methodWithException", TestObjInternal::methodWithExceptionCallback}, {"customMethod", V8TestObj::customMethodCallback}, {"customMethodWithArgs", V8TestObj::customMethodWithArgsCallback}, + {"addEventListener", TestObjInternal::addEventListenerCallback}, + {"removeEventListener", TestObjInternal::removeEventListenerCallback}, + {"withDynamicFrame", TestObjInternal::withDynamicFrameCallback}, + {"withDynamicFrameAndArg", TestObjInternal::withDynamicFrameAndArgCallback}, + {"withDynamicFrameAndOptionalArg", TestObjInternal::withDynamicFrameAndOptionalArgCallback}, + {"withDynamicFrameAndUserGesture", TestObjInternal::withDynamicFrameAndUserGestureCallback}, + {"withDynamicFrameAndUserGestureASAD", TestObjInternal::withDynamicFrameAndUserGestureASADCallback}, + {"withScriptStateVoid", TestObjInternal::withScriptStateVoidCallback}, + {"withScriptStateObj", TestObjInternal::withScriptStateObjCallback}, + {"withScriptStateVoidException", TestObjInternal::withScriptStateVoidExceptionCallback}, + {"withScriptStateObjException", TestObjInternal::withScriptStateObjExceptionCallback}, {"methodWithOptionalArg", TestObjInternal::methodWithOptionalArgCallback}, {"methodWithNonOptionalArgAndOptionalArg", TestObjInternal::methodWithNonOptionalArgAndOptionalArgCallback}, {"methodWithNonOptionalArgAndTwoOptionalArgs", TestObjInternal::methodWithNonOptionalArgAndTwoOptionalArgsCallback}, @@ -395,6 +644,12 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv); proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + // Custom Signature 'customArgsAndException' + const int customArgsAndExceptionArgc = 1; + v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; + v8::Handle<v8::Signature> customArgsAndExceptionSignature = v8::Signature::New(desc, customArgsAndExceptionArgc, customArgsAndExceptionArgv); + proto->Set(v8::String::New("customArgsAndException"), v8::FunctionTemplate::New(TestObjInternal::customArgsAndExceptionCallback, v8::Handle<v8::Value>(), customArgsAndExceptionSignature)); + // Custom toString template desc->Set(getToStringName(), getToStringTemplate()); return desc; diff --git a/WebCore/bindings/v8/test/V8TestObj.h b/WebCore/bindings/scripts/test/V8/V8TestObj.h index 5d6770a..5d6770a 100644 --- a/WebCore/bindings/v8/test/V8TestObj.h +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.h diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp index 95e874b..6ca952e 100644 --- a/WebCore/bindings/v8/ScriptCallStack.cpp +++ b/WebCore/bindings/v8/ScriptCallStack.cpp @@ -33,13 +33,16 @@ #include "ScriptController.h" #include "ScriptDebugServer.h" +#include "V8Binding.h" +#include <v8-debug.h> #include <v8.h> - -#include "V8Binding.h" +#include <wtf/StdLibExtras.h> // For DEFINE_STATIC_LOCAL namespace WebCore { +v8::Persistent<v8::Context> ScriptCallStack::s_utilityContext; + ScriptCallStack* ScriptCallStack::create(const v8::Arguments& arguments, unsigned skipArgumentCount) { String sourceName; int sourceLineNumber; @@ -51,10 +54,14 @@ ScriptCallStack* ScriptCallStack::create(const v8::Arguments& arguments, unsigne bool ScriptCallStack::callLocation(String* sourceName, int* sourceLineNumber, String* functionName) { +<<<<<<< HEAD:WebCore/bindings/v8/ScriptCallStack.cpp #if PLATFORM(ANDROID) return false; #else if (!ScriptDebugServer::topStackFrame(*sourceName, *sourceLineNumber, *functionName)) +======= + if (!topStackFrame(*sourceName, *sourceLineNumber, *functionName)) +>>>>>>> webkit.org at r58956:WebCore/bindings/v8/ScriptCallStack.cpp return false; *sourceLineNumber += 1; return true; @@ -79,4 +86,67 @@ const ScriptCallFrame& ScriptCallStack::at(unsigned index) const return m_lastCaller; } +// Create the utility context for holding JavaScript functions used internally +// which are not visible to JavaScript executing on the page. +void ScriptCallStack::createUtilityContext() +{ + ASSERT(s_utilityContext.IsEmpty()); + + v8::HandleScope scope; + v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); + s_utilityContext = v8::Context::New(0, globalTemplate); + v8::Context::Scope contextScope(s_utilityContext); + + // Compile JavaScript function for retrieving the source line, the source + // name and the symbol name for the top JavaScript stack frame. + DEFINE_STATIC_LOCAL(const char*, topStackFrame, + ("function topStackFrame(exec_state) {" + " if (!exec_state.frameCount())" + " return undefined;" + " var frame = exec_state.frame(0);" + " var func = frame.func();" + " var scriptName;" + " if (func.resolved() && func.script())" + " scriptName = func.script().name();" + " return [scriptName, frame.sourceLine(), (func.name() || func.inferredName())];" + "}")); + v8::Script::Compile(v8::String::New(topStackFrame))->Run(); +} + +bool ScriptCallStack::topStackFrame(String& sourceName, int& lineNumber, String& functionName) +{ + v8::HandleScope scope; + v8::Handle<v8::Context> v8UtilityContext = utilityContext(); + if (v8UtilityContext.IsEmpty()) + return false; + v8::Context::Scope contextScope(v8UtilityContext); + v8::Handle<v8::Function> topStackFrame; + topStackFrame = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("topStackFrame"))); + if (topStackFrame.IsEmpty()) + return false; + v8::Handle<v8::Value> value = v8::Debug::Call(topStackFrame); + if (value.IsEmpty()) + return false; + // If there is no top stack frame, we still return success, but fill the input params with defaults. + if (value->IsUndefined()) { + // Fallback to setting lineNumber to 0, and source and function name to "undefined". + sourceName = toWebCoreString(value); + lineNumber = 0; + functionName = toWebCoreString(value); + return true; + } + if (!value->IsArray()) + return false; + v8::Local<v8::Object> jsArray = value->ToObject(); + v8::Local<v8::Value> sourceNameValue = jsArray->Get(0); + v8::Local<v8::Value> lineNumberValue = jsArray->Get(1); + v8::Local<v8::Value> functionNameValue = jsArray->Get(2); + if (sourceNameValue.IsEmpty() || lineNumberValue.IsEmpty() || functionNameValue.IsEmpty()) + return false; + sourceName = toWebCoreString(sourceNameValue); + lineNumber = lineNumberValue->Int32Value(); + functionName = toWebCoreString(functionNameValue); + return true; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptCallStack.h b/WebCore/bindings/v8/ScriptCallStack.h index 2433bde..11ec3bb 100644 --- a/WebCore/bindings/v8/ScriptCallStack.h +++ b/WebCore/bindings/v8/ScriptCallStack.h @@ -42,26 +42,48 @@ namespace v8 { namespace WebCore { - class ScriptCallStack : public Noncopyable { - public: - static ScriptCallStack* create(const v8::Arguments&, unsigned skipArgumentCount = 0); - ~ScriptCallStack(); - - static bool callLocation(String* sourceName, int* sourceLineNumber, String* functionName); - - const ScriptCallFrame& at(unsigned) const; - // FIXME: implement retrieving and storing call stack trace - unsigned size() const { return 1; } - - ScriptState* state() const { return m_scriptState; } - ScriptState* globalState() const { return m_scriptState; } - - private: - ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String funcName); - - ScriptCallFrame m_lastCaller; - ScriptState* m_scriptState; - }; +class ScriptCallStack : public Noncopyable { +public: + static ScriptCallStack* create(const v8::Arguments&, unsigned skipArgumentCount = 0); + ~ScriptCallStack(); + + static bool callLocation(String* sourceName, int* sourceLineNumber, String* functionName); + + const ScriptCallFrame& at(unsigned) const; + // FIXME: implement retrieving and storing call stack trace + unsigned size() const { return 1; } + + ScriptState* state() const { return m_scriptState; } + ScriptState* globalState() const { return m_scriptState; } + +private: + ScriptCallStack(const v8::Arguments& arguments, unsigned skipArgumentCount, String sourceName, int sourceLineNumber, String funcName); + + // Function for retrieving the source name, line number and function name for the top + // JavaScript stack frame. + // + // It will return true if the caller information was successfully retrieved and written + // into the function parameters, otherwise the function will return false. It may + // fail due to a stack overflow in the underlying JavaScript implementation, handling + // of such exception is up to the caller. + static bool topStackFrame(String& sourceName, int& lineNumber, String& functionName); + + static void createUtilityContext(); + + // Returns a local handle of the utility context. + static v8::Local<v8::Context> utilityContext() + { + if (s_utilityContext.IsEmpty()) + createUtilityContext(); + return v8::Local<v8::Context>::New(s_utilityContext); + } + + ScriptCallFrame m_lastCaller; + ScriptState* m_scriptState; + + // Utility context holding JavaScript functions used internally. + static v8::Persistent<v8::Context> s_utilityContext; +}; } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index ee15eaa..0f94a2e 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -68,6 +68,7 @@ void ScriptController::initializeThreading() static bool initializedThreading = false; if (!initializedThreading) { WTF::initializeThreading(); + WTF::initializeMainThread(); initializedThreading = true; } } diff --git a/WebCore/bindings/v8/ScriptDebugServer.cpp b/WebCore/bindings/v8/ScriptDebugServer.cpp index 54d7694..ce258fb 100644 --- a/WebCore/bindings/v8/ScriptDebugServer.cpp +++ b/WebCore/bindings/v8/ScriptDebugServer.cpp @@ -44,8 +44,6 @@ namespace WebCore { -v8::Persistent<v8::Context> ScriptDebugServer::s_utilityContext; - ScriptDebugServer::MessageLoopDispatchHandler ScriptDebugServer::s_messageLoopDispatchHandler = 0; ScriptDebugServer& ScriptDebugServer::shared() @@ -81,11 +79,10 @@ void ScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page) m_listenersMap.set(page, listener); V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame()); v8::Local<v8::Context> context = proxy->mainWorldContext(); - String contextData = toWebCoreStringWithNullCheck(context->GetData()); - m_contextDataMap.set(listener, contextData); v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("getScripts"))); - v8::Handle<v8::Value> value = v8::Debug::Call(getScriptsFunction); + v8::Handle<v8::Value> argv[] = { context->GetData() }; + v8::Handle<v8::Value> value = getScriptsFunction->Call(m_debuggerScript.get(), 1, argv); if (value.IsEmpty()) return; ASSERT(!value->IsUndefined() && value->IsArray()); @@ -175,6 +172,35 @@ void ScriptDebugServer::setBreakpointsActivated(bool enabled) #endif } +ScriptDebugServer::PauseOnExceptionsState ScriptDebugServer::pauseOnExceptionsState() +{ +#if ENABLE(V8_SCRIPT_DEBUG_SERVER) + ensureDebuggerScriptCompiled(); + v8::HandleScope scope; + v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); + + v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("pauseOnExceptionsState"))); + v8::Handle<v8::Value> argv[] = { v8::Handle<v8::Value>() }; + v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 0, argv); + return static_cast<ScriptDebugServer::PauseOnExceptionsState>(result->Int32Value()); +#else + return DontPauseOnExceptions; +#endif +} + +void ScriptDebugServer::setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) +{ +#if ENABLE(V8_SCRIPT_DEBUG_SERVER) + ensureDebuggerScriptCompiled(); + v8::HandleScope scope; + v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); + + v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("setPauseOnExceptionsState"))); + v8::Handle<v8::Value> argv[] = { v8::Int32::New(pauseOnExceptionsState) }; + currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); +#endif +} + void ScriptDebugServer::continueProgram() { #if ENABLE(V8_SCRIPT_DEBUG_SERVER) @@ -216,26 +242,15 @@ ScriptState* ScriptDebugServer::currentCallFrameState() return m_currentCallFrameState; } -v8::Handle<v8::Value> ScriptDebugServer::currentCallFrameV8() -{ -#if ENABLE(V8_SCRIPT_DEBUG_SERVER) - if (!m_currentCallFrame.get().IsEmpty()) - return m_currentCallFrame.get(); - - // Check on a bp. - v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); - v8::Handle<v8::Value> argv[] = { m_executionState.get() }; - v8::Handle<v8::Value> result = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); - m_currentCallFrame.set(result); - return result; -#else - return v8::Handle<v8::Value>(); -#endif -} - PassRefPtr<JavaScriptCallFrame> ScriptDebugServer::currentCallFrame() { - return JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8())); + if (!m_currentCallFrame) { + v8::Handle<v8::Function> currentCallFrameFunction = v8::Local<v8::Function>::Cast(m_debuggerScript.get()->Get(v8::String::New("currentCallFrame"))); + v8::Handle<v8::Value> argv[] = { m_executionState.get() }; + v8::Handle<v8::Value> currentCallFrameV8 = currentCallFrameFunction->Call(m_debuggerScript.get(), 1, argv); + m_currentCallFrame = JavaScriptCallFrame::create(v8::Debug::GetDebugContext(), v8::Handle<v8::Object>::Cast(currentCallFrameV8)); + } + return m_currentCallFrame; } void ScriptDebugServer::onV8DebugMessage(const v8::Debug::Message& message) @@ -268,7 +283,7 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message) return; // Ignore unsupported event types. - if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break) + if (message.GetEvent() != v8::AfterCompile && message.GetEvent() != v8::Break && message.GetEvent() != v8::Exception) return; v8::Handle<v8::Context> context = message.GetEventContext(); @@ -286,11 +301,13 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message) if (global.IsEmpty()) return; + bool handled = false; Frame* frame = V8Proxy::retrieveFrame(context); if (frame) { ScriptDebugListener* listener = m_listenersMap.get(frame->page()); if (listener) { if (message.GetEvent() == v8::AfterCompile) { + handled = true; v8::Context::Scope contextScope(v8::Debug::GetDebugContext()); v8::Local<v8::Object> args = v8::Object::New(); args->Set(v8::String::New("eventData"), message.GetEventData()); @@ -300,7 +317,8 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message) ASSERT(value->IsObject()); v8::Handle<v8::Object> object = v8::Handle<v8::Object>::Cast(value); dispatchDidParseSource(listener, object); - } else if (message.GetEvent() == v8::Break) { + } else if (message.GetEvent() == v8::Break || message.GetEvent() == v8::Exception) { + handled = true; m_executionState.set(message.GetExecutionState()); m_currentCallFrameState = mainWorldScriptState(frame); listener->didPause(); @@ -308,14 +326,13 @@ void ScriptDebugServer::handleV8DebugMessage(const v8::Debug::Message& message) } } } + + if (!handled && !message.WillStartRunning()) + continueProgram(); } void ScriptDebugServer::dispatchDidParseSource(ScriptDebugListener* listener, v8::Handle<v8::Object> object) { - String contextData = toWebCoreStringWithNullCheck(object->Get(v8::String::New("contextData"))); - if (contextData != m_contextDataMap.get(listener)) - return; - listener->didParseSource( toWebCoreStringWithNullCheck(object->Get(v8::String::New("id"))), toWebCoreStringWithNullCheck(object->Get(v8::String::New("name"))), @@ -339,69 +356,6 @@ void ScriptDebugServer::didResume() m_executionState.clear(); } -// Create the utility context for holding JavaScript functions used internally -// which are not visible to JavaScript executing on the page. -void ScriptDebugServer::createUtilityContext() -{ - ASSERT(s_utilityContext.IsEmpty()); - - v8::HandleScope scope; - v8::Handle<v8::ObjectTemplate> globalTemplate = v8::ObjectTemplate::New(); - s_utilityContext = v8::Context::New(0, globalTemplate); - v8::Context::Scope contextScope(s_utilityContext); - - // Compile JavaScript function for retrieving the source line, the source - // name and the symbol name for the top JavaScript stack frame. - DEFINE_STATIC_LOCAL(const char*, topStackFrame, - ("function topStackFrame(exec_state) {" - " if (!exec_state.frameCount())" - " return undefined;" - " var frame = exec_state.frame(0);" - " var func = frame.func();" - " var scriptName;" - " if (func.resolved() && func.script())" - " scriptName = func.script().name();" - " return [scriptName, frame.sourceLine(), (func.name() || func.inferredName())];" - "}")); - v8::Script::Compile(v8::String::New(topStackFrame))->Run(); -} - -bool ScriptDebugServer::topStackFrame(String& sourceName, int& lineNumber, String& functionName) -{ - v8::HandleScope scope; - v8::Handle<v8::Context> v8UtilityContext = utilityContext(); - if (v8UtilityContext.IsEmpty()) - return false; - v8::Context::Scope contextScope(v8UtilityContext); - v8::Handle<v8::Function> topStackFrame; - topStackFrame = v8::Local<v8::Function>::Cast(v8UtilityContext->Global()->Get(v8::String::New("topStackFrame"))); - if (topStackFrame.IsEmpty()) - return false; - v8::Handle<v8::Value> value = v8::Debug::Call(topStackFrame); - if (value.IsEmpty()) - return false; - // If there is no top stack frame, we still return success, but fill the input params with defaults. - if (value->IsUndefined()) { - // Fallback to setting lineNumber to 0, and source and function name to "undefined". - sourceName = toWebCoreString(value); - lineNumber = 0; - functionName = toWebCoreString(value); - return true; - } - if (!value->IsArray()) - return false; - v8::Local<v8::Object> jsArray = value->ToObject(); - v8::Local<v8::Value> sourceNameValue = jsArray->Get(0); - v8::Local<v8::Value> lineNumberValue = jsArray->Get(1); - v8::Local<v8::Value> functionNameValue = jsArray->Get(2); - if (sourceNameValue.IsEmpty() || lineNumberValue.IsEmpty() || functionNameValue.IsEmpty()) - return false; - sourceName = toWebCoreString(sourceNameValue); - lineNumber = lineNumberValue->Int32Value(); - functionName = toWebCoreString(functionNameValue); - return true; -} - } // namespace WebCore #endif // ENABLE(JAVASCRIPT_DEBUGGER) diff --git a/WebCore/bindings/v8/ScriptDebugServer.h b/WebCore/bindings/v8/ScriptDebugServer.h index 04857e4..6ef0afd 100644 --- a/WebCore/bindings/v8/ScriptDebugServer.h +++ b/WebCore/bindings/v8/ScriptDebugServer.h @@ -33,7 +33,7 @@ #if ENABLE(JAVASCRIPT_DEBUGGER) -#include "OwnHandle.h" +#include "JavaScriptCallFrame.h" #include "PlatformString.h" #include "ScriptBreakpoint.h" #include "ScriptState.h" @@ -45,22 +45,12 @@ namespace WebCore { -class JavaScriptCallFrame; class Page; class ScriptDebugListener; class ScriptDebugServer : public Noncopyable { public: static ScriptDebugServer& shared(); - - // Function for retrieving the source name, line number and function name for the top - // JavaScript stack frame. - // - // It will return true if the caller information was successfully retrieved and written - // into the function parameters, otherwise the function will return false. It may - // fail due to a stack overflow in the underlying JavaScript implementation, handling - // of such exception is up to the caller. - static bool topStackFrame(String& sourceName, int& lineNumber, String& functionName); void addListener(ScriptDebugListener*, Page*); void removeListener(ScriptDebugListener*, Page*); @@ -75,8 +65,8 @@ public: PauseOnAllExceptions, PauseOnUncaughtExceptions }; - PauseOnExceptionsState pauseOnExceptionsState() const { return m_pauseOnExceptionsState; } - void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState) { m_pauseOnExceptionsState = pauseOnExceptionsState; } + PauseOnExceptionsState pauseOnExceptionsState(); + void setPauseOnExceptionsState(PauseOnExceptionsState pauseOnExceptionsState); void pauseProgram() { } void continueProgram(); @@ -97,7 +87,6 @@ public: typedef void (*MessageLoopDispatchHandler)(const Vector<WebCore::Page*>&); static void setMessageLoopDispatchHandler(MessageLoopDispatchHandler messageLoopDispatchHandler) { s_messageLoopDispatchHandler = messageLoopDispatchHandler; } - v8::Handle<v8::Value> currentCallFrameV8(); PassRefPtr<JavaScriptCallFrame> currentCallFrame(); private: @@ -115,28 +104,13 @@ private: void ensureDebuggerScriptCompiled(); void didResume(); - static void createUtilityContext(); - - // Returns a local handle of the utility context. - static v8::Local<v8::Context> utilityContext() - { - if (s_utilityContext.IsEmpty()) - createUtilityContext(); - return v8::Local<v8::Context>::New(s_utilityContext); - } - - // Utility context holding JavaScript functions used internally. - static v8::Persistent<v8::Context> s_utilityContext; - typedef HashMap<Page*, ScriptDebugListener*> ListenersMap; ListenersMap m_listenersMap; - typedef HashMap<ScriptDebugListener*, String> ContextDataMap; - ContextDataMap m_contextDataMap; String m_debuggerScriptSource; PauseOnExceptionsState m_pauseOnExceptionsState; OwnHandle<v8::Object> m_debuggerScript; ScriptState* m_currentCallFrameState; - OwnHandle<v8::Value> m_currentCallFrame; + RefPtr<JavaScriptCallFrame> m_currentCallFrame; OwnHandle<v8::Object> m_executionState; static MessageLoopDispatchHandler s_messageLoopDispatchHandler; diff --git a/WebCore/bindings/v8/ScriptEventListener.cpp b/WebCore/bindings/v8/ScriptEventListener.cpp index fdb6076..cad7a1c 100644 --- a/WebCore/bindings/v8/ScriptEventListener.cpp +++ b/WebCore/bindings/v8/ScriptEventListener.cpp @@ -106,7 +106,7 @@ PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame* frame, Attri return V8LazyEventListener::create(attr->localName().string(), frame->document()->isSVGDocument(), attr->value(), sourceURL, lineNumber, columnNumber, WorldContextHandle(UseMainWorld)); } -String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* listener) +String eventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* listener) { if (listener->type() != EventListener::JSEventListenerType) return ""; @@ -120,4 +120,25 @@ String getEventListenerHandlerBody(ScriptExecutionContext* context, ScriptState* return toWebCoreStringWithNullCheck(function); } +bool eventListenerHandlerLocation(ScriptExecutionContext* context, ScriptState* scriptState, EventListener* listener, String& sourceName, int& lineNumber) +{ + if (listener->type() != EventListener::JSEventListenerType) + return false; + + ScriptScope scope(scriptState); + V8AbstractEventListener* v8Listener = static_cast<V8AbstractEventListener*>(listener); + v8::Handle<v8::Object> object = v8Listener->getListenerObject(context); + if (object.IsEmpty() || !object->IsFunction()) + return false; + + v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(object); + v8::ScriptOrigin origin = function->GetScriptOrigin(); + if (!origin.ResourceName().IsEmpty()) { + sourceName = toWebCoreString(origin.ResourceName()); + lineNumber = function->GetScriptLineNumber() + 1; + return true; + } + return false; +} + } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptEventListener.h b/WebCore/bindings/v8/ScriptEventListener.h index ce12a53..7815e29 100644 --- a/WebCore/bindings/v8/ScriptEventListener.h +++ b/WebCore/bindings/v8/ScriptEventListener.h @@ -45,7 +45,8 @@ namespace WebCore { PassRefPtr<V8LazyEventListener> createAttributeEventListener(Node*, Attribute*); PassRefPtr<V8LazyEventListener> createAttributeEventListener(Frame*, Attribute*); - String getEventListenerHandlerBody(ScriptExecutionContext*, ScriptState*, EventListener*); + String eventListenerHandlerBody(ScriptExecutionContext*, ScriptState*, EventListener*); + bool eventListenerHandlerLocation(ScriptExecutionContext*, ScriptState*, EventListener*, String& sourceName, int& lineNumber); } // namespace WebCore diff --git a/WebCore/bindings/v8/ScriptProfileNode.cpp b/WebCore/bindings/v8/ScriptProfileNode.cpp index 3121128..7266c29 100644 --- a/WebCore/bindings/v8/ScriptProfileNode.cpp +++ b/WebCore/bindings/v8/ScriptProfileNode.cpp @@ -55,14 +55,12 @@ unsigned long ScriptProfileNode::lineNumber() const double ScriptProfileNode::totalTime() const { - // FIXME: use GetTotalMilliseconds once it is implemented in V8. - return m_profileNode->GetTotalSamplesCount(); + return m_profileNode->GetTotalTime(); } double ScriptProfileNode::selfTime() const { - // FIXME: use GetSelfMilliseconds once it is implemented in V8. - return m_profileNode->GetSelfSamplesCount(); + return m_profileNode->GetSelfTime(); } unsigned long ScriptProfileNode::numberOfCalls() const diff --git a/WebCore/bindings/v8/V8AbstractEventListener.cpp b/WebCore/bindings/v8/V8AbstractEventListener.cpp index 6dc2b29..b6c53df 100644 --- a/WebCore/bindings/v8/V8AbstractEventListener.cpp +++ b/WebCore/bindings/v8/V8AbstractEventListener.cpp @@ -71,6 +71,8 @@ V8AbstractEventListener::~V8AbstractEventListener() void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event* event) { + ASSERT(event); + // The callback function on XMLHttpRequest can clear the event listener and destroys 'this' object. Keep a local reference to it. // See issue 889829. RefPtr<V8AbstractEventListener> protect(this); @@ -86,6 +88,7 @@ void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event // Get the V8 wrapper for the event object. v8::Handle<v8::Value> jsEvent = toV8(event); + ASSERT(!jsEvent.IsEmpty()); invokeEventHandler(context, event, jsEvent); } @@ -114,6 +117,9 @@ void V8AbstractEventListener::setListenerObject(v8::Handle<v8::Object> listener) void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context, Event* event, v8::Handle<v8::Value> jsEvent) { + // If jsEvent is empty, attempt to set it as a hidden value would crash v8. + if (jsEvent.IsEmpty()) + return; v8::Local<v8::Context> v8Context = toV8Context(context, worldContext()); if (v8Context.IsEmpty()) diff --git a/WebCore/bindings/v8/V8GCController.cpp b/WebCore/bindings/v8/V8GCController.cpp index 61b2a88..fa7c357 100644 --- a/WebCore/bindings/v8/V8GCController.cpp +++ b/WebCore/bindings/v8/V8GCController.cpp @@ -378,7 +378,12 @@ public: ActiveDOMObject* activeDOMObject = typeInfo->toActiveDOMObject(wrapper); if (activeDOMObject && activeDOMObject->hasPendingActivity()) { ASSERT(!wrapper.IsWeak()); - wrapper.MakeWeak(activeDOMObject, &DOMDataStore::weakActiveDOMObjectCallback); + // NOTE: To re-enable weak status of the active object we use + // |object| from the map and not |activeDOMObject|. The latter + // may be a different pointer (in case ActiveDOMObject is not + // the main base class of the object's class) and pointer + // identity is required by DOM map functions. + wrapper.MakeWeak(object, &DOMDataStore::weakActiveDOMObjectCallback); } } } diff --git a/WebCore/bindings/v8/V8NPObject.cpp b/WebCore/bindings/v8/V8NPObject.cpp index 1ea6487..84450e5 100644 --- a/WebCore/bindings/v8/V8NPObject.cpp +++ b/WebCore/bindings/v8/V8NPObject.cpp @@ -33,7 +33,6 @@ #include "V8NPObject.h" #include "HTMLPlugInElement.h" -#include "IdentifierRep.h" #include "NPV8Object.h" #include "V8DOMMap.h" #include "V8HTMLAppletElement.h" @@ -54,6 +53,17 @@ enum InvokeFunctionType { InvokeDefault = 3 }; +struct IdentifierRep { + int number() const { return m_isString ? 0 : m_value.m_number; } + const char* string() const { return m_isString ? m_value.m_string : 0; } + + union { + const char* m_string; + int m_number; + } m_value; + bool m_isString; +}; + // FIXME: need comments. // Params: holder could be HTMLEmbedElement or NPObject static v8::Handle<v8::Value> npObjectInvokeImpl(const v8::Arguments& args, InvokeFunctionType functionId) diff --git a/WebCore/bindings/v8/V8Proxy.cpp b/WebCore/bindings/v8/V8Proxy.cpp index 0543037..7f52374 100644 --- a/WebCore/bindings/v8/V8Proxy.cpp +++ b/WebCore/bindings/v8/V8Proxy.cpp @@ -505,7 +505,7 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8 #if ENABLE(INSPECTOR) Page* inspectedPage = InspectorTimelineAgent::instanceCount() ? m_frame->page(): 0; - if (inspectedPage) + if (inspectedPage) { if (InspectorTimelineAgent* timelineAgent = inspectedPage->inspectorTimelineAgent()) { v8::ScriptOrigin origin = function->GetScriptOrigin(); String resourceName("undefined"); @@ -517,6 +517,7 @@ v8::Local<v8::Value> V8Proxy::callFunction(v8::Handle<v8::Function> function, v8 timelineAgent->willCallFunction(resourceName, lineNumber); } else inspectedPage = 0; + } #endif // !ENABLE(INSPECTOR) m_recursion++; diff --git a/WebCore/bindings/v8/V8Proxy.h b/WebCore/bindings/v8/V8Proxy.h index 98bc902..cd2ddad 100644 --- a/WebCore/bindings/v8/V8Proxy.h +++ b/WebCore/bindings/v8/V8Proxy.h @@ -39,6 +39,7 @@ #include "V8DOMWindowShell.h" #include "V8DOMWrapper.h" #include "V8GCController.h" +#include "V8Utilities.h" #include "WrapperTypeInfo.h" #include <v8.h> #include <wtf/PassRefPtr.h> // so generated bindings don't have to @@ -304,6 +305,9 @@ namespace WebCore { template <typename T> static v8::Handle<v8::Value> constructDOMObject(const v8::Arguments&, WrapperTypeInfo*); + template <typename T> + static v8::Handle<v8::Value> constructDOMObjectWithScriptExecutionContext(const v8::Arguments&, WrapperTypeInfo*); + // Process any pending JavaScript console messages. static void processConsoleMessages(); @@ -409,6 +413,25 @@ namespace WebCore { return args.Holder(); } + template <typename T> + v8::Handle<v8::Value> V8Proxy::constructDOMObjectWithScriptExecutionContext(const v8::Arguments& args, WrapperTypeInfo* type) + { + if (!args.IsConstructCall()) + return throwError(V8Proxy::TypeError, ""); + + ScriptExecutionContext* context = getScriptExecutionContext(); + if (!context) + return throwError(V8Proxy::ReferenceError, ""); + + // Note: it's OK to let this RefPtr go out of scope because we also call + // SetDOMWrapper(), which effectively holds a reference to obj. + RefPtr<T> obj = T::create(context); + V8DOMWrapper::setDOMWrapper(args.Holder(), type, obj.get()); + obj->ref(); + V8DOMWrapper::setJSWrapperForDOMObject(obj.get(), v8::Persistent<v8::Object>::New(args.Holder())); + return args.Holder(); + } + v8::Local<v8::Context> toV8Context(ScriptExecutionContext*, const WorldContextHandle& worldContext); diff --git a/WebCore/bindings/v8/WorkerScriptController.h b/WebCore/bindings/v8/WorkerScriptController.h index 616697a..5e3159f 100644 --- a/WebCore/bindings/v8/WorkerScriptController.h +++ b/WebCore/bindings/v8/WorkerScriptController.h @@ -58,6 +58,7 @@ namespace WebCore { enum ForbidExecutionOption { TerminateRunningScript, LetRunningScriptFinish }; void forbidExecution(ForbidExecutionOption); + bool isExecutionForbidden() const { return m_executionForbidden; } // Returns WorkerScriptController for the currently executing context. 0 will be returned if the current executing context is not the worker context. static WorkerScriptController* controllerForContext(); diff --git a/WebCore/bindings/v8/WorldContextHandle.cpp b/WebCore/bindings/v8/WorldContextHandle.cpp index 7ba76d3..24f461f 100644 --- a/WebCore/bindings/v8/WorldContextHandle.cpp +++ b/WebCore/bindings/v8/WorldContextHandle.cpp @@ -47,10 +47,9 @@ WorldContextHandle::WorldContextHandle(WorldToUse worldToUse) v8::Local<v8::Context> WorldContextHandle::adjustedContext(V8Proxy* proxy) const { - if (m_worldToUse == UseMainWorld) + if (m_worldToUse == UseMainWorld || !m_context || m_context->get().IsEmpty()) return proxy->mainWorldContext(); - if (!m_context || m_context->get().IsEmpty()) - return proxy->context(); + return v8::Local<v8::Context>::New(m_context->get()); } diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp index 9026420..4cc6ac2 100644 --- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp @@ -42,17 +42,11 @@ namespace WebCore { typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; -v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String>, const v8::AccessorInfo&) { INC_STATS("DOM.Console.profilesAccessorGetter"); - Console* imp = V8Console::toNative(info.Holder()); - const ProfilesArray& profiles = imp->profiles(); - v8::Handle<v8::Array> result = v8::Array::New(profiles.size()); - int index = 0; - ProfilesArray::const_iterator end = profiles.end(); - for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter) - result->Set(v8::Integer::New(index++), toV8(iter->get())); - return result; + // FIXME: Provide a real implementation. + return v8::Array::New(0); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp deleted file mode 100644 index df0cc53..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(DATABASE) - -#include "V8CustomSQLStatementCallback.h" - -#include "Frame.h" -#include "ScriptExecutionContext.h" -#include "V8CustomVoidCallback.h" -#include "V8SQLResultSet.h" -#include "V8SQLTransaction.h" - -namespace WebCore { - -V8CustomSQLStatementCallback::V8CustomSQLStatementCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) - , m_worldContext(UseCurrentWorld) -{ -} - -V8CustomSQLStatementCallback::~V8CustomSQLStatementCallback() -{ - m_callback.Dispose(); -} - -void V8CustomSQLStatementCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException) -{ - v8::HandleScope handleScope; - - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); - if (v8Context.IsEmpty()) - return; - - v8::Context::Scope scope(v8Context); - - v8::Handle<v8::Value> argv[] = { - toV8(transaction), - toV8(resultSet) - }; - - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); - - bool callbackReturnValue = false; - raisedException = invokeCallback(m_callback, 2, argv, callbackReturnValue); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.h b/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.h deleted file mode 100644 index 31f53e4..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementCallback.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef V8CustomSQLStatementCallback_h -#define V8CustomSQLStatementCallback_h - -#if ENABLE(DATABASE) - -#include "SQLStatementCallback.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/Forward.h> - -namespace WebCore { - -class Frame; - -class V8CustomSQLStatementCallback : public SQLStatementCallback { -public: - static PassRefPtr<V8CustomSQLStatementCallback> create(v8::Local<v8::Value> value, Frame* frame) - { - ASSERT(value->IsObject()); - return adoptRef(new V8CustomSQLStatementCallback(value->ToObject(), frame)); - } - virtual ~V8CustomSQLStatementCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLResultSet*, bool& raisedException); -private: - V8CustomSQLStatementCallback(v8::Local<v8::Object>, Frame*); - - v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; - WorldContextHandle m_worldContext; -}; - -} // namespace WebCore - -#endif - -#endif // V8CustomSQLStatementCallback_h diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp index 2545f24..e033684 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp @@ -32,7 +32,7 @@ #if ENABLE(DATABASE) -#include "V8CustomSQLStatementErrorCallback.h" +#include "V8SQLStatementErrorCallback.h" #include "Frame.h" #include "ScriptExecutionContext.h" @@ -42,19 +42,7 @@ namespace WebCore { -V8CustomSQLStatementErrorCallback::V8CustomSQLStatementErrorCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) - , m_worldContext(UseCurrentWorld) -{ -} - -V8CustomSQLStatementErrorCallback::~V8CustomSQLStatementErrorCallback() -{ - m_callback.Dispose(); -} - -bool V8CustomSQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error) +bool V8SQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, SQLError* error) { v8::HandleScope handleScope; diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.h b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.h deleted file mode 100644 index c3d7f79..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef V8CustomSQLStatementErrorCallback_h -#define V8CustomSQLStatementErrorCallback_h - -#if ENABLE(DATABASE) - -#include "SQLStatementErrorCallback.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - -class Frame; - -class V8CustomSQLStatementErrorCallback : public SQLStatementErrorCallback { -public: - static PassRefPtr<V8CustomSQLStatementErrorCallback> create(v8::Local<v8::Value> value, Frame* frame) - { - ASSERT(value->IsObject()); - return adoptRef(new V8CustomSQLStatementErrorCallback(value->ToObject(), frame)); - } - virtual ~V8CustomSQLStatementErrorCallback(); - - virtual bool handleEvent(ScriptExecutionContext*, SQLTransaction*, SQLError*); -private: - V8CustomSQLStatementErrorCallback(v8::Local<v8::Object>, Frame*); - - v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; - WorldContextHandle m_worldContext; -}; - -} // namespace WebCore - -#endif - -#endif // V8CustomSQLStatementErrorCallback_h diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp deleted file mode 100644 index efe415c..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2009, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(DATABASE) - -#include "V8CustomSQLTransactionCallback.h" - -#include "Frame.h" -#include "ScriptExecutionContext.h" -#include "V8CustomVoidCallback.h" -#include "V8SQLTransaction.h" - -namespace WebCore { - -V8CustomSQLTransactionCallback::V8CustomSQLTransactionCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) - , m_worldContext(UseCurrentWorld) -{ -} - -V8CustomSQLTransactionCallback::~V8CustomSQLTransactionCallback() -{ - m_callback.Dispose(); -} - - -void V8CustomSQLTransactionCallback::handleEvent(ScriptExecutionContext* context, SQLTransaction* transaction, bool& raisedException) -{ - v8::HandleScope handleScope; - - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); - if (v8Context.IsEmpty()) - return; - - v8::Context::Scope scope(v8Context); - - v8::Handle<v8::Value> argv[] = { - toV8(transaction) - }; - - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); - - // Step 5: If the callback couldn't be called (e.g. it was null) or if - // the callback was invoked and raised an exception, jump to the last - // step (rollback transaction). - bool callbackReturnValue = false; - raisedException = invokeCallback(m_callback, 1, argv, callbackReturnValue); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.h b/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.h deleted file mode 100644 index 60ad529..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionCallback.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef V8CustomSQLTransactionCallback_h -#define V8CustomSQLTransactionCallback_h - -#if ENABLE(DATABASE) - -#include "SQLTransactionCallback.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/Forward.h> - -namespace WebCore { - -class Frame; - -class V8CustomSQLTransactionCallback : public SQLTransactionCallback { -public: - static PassRefPtr<V8CustomSQLTransactionCallback> create(v8::Local<v8::Value> value, Frame* frame) - { - ASSERT(value->IsObject()); - return adoptRef(new V8CustomSQLTransactionCallback(value->ToObject(), frame)); - } - virtual ~V8CustomSQLTransactionCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLTransaction*, bool& raisedException); -private: - V8CustomSQLTransactionCallback(v8::Local<v8::Object>, Frame*); - - v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; - WorldContextHandle m_worldContext; -}; - -} // namespace WebCore - -#endif - -#endif // V8CustomSQLTransactionCallback_h diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp deleted file mode 100644 index 1ef711a..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2009, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(DATABASE) - -#include "V8CustomSQLTransactionErrorCallback.h" - -#include "Frame.h" -#include "ScriptExecutionContext.h" -#include "V8CustomVoidCallback.h" -#include "V8SQLError.h" - -namespace WebCore { - -V8CustomSQLTransactionErrorCallback::V8CustomSQLTransactionErrorCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) - , m_worldContext(UseCurrentWorld) -{ -} - -V8CustomSQLTransactionErrorCallback::~V8CustomSQLTransactionErrorCallback() -{ - m_callback.Dispose(); -} - -void V8CustomSQLTransactionErrorCallback::handleEvent(ScriptExecutionContext* context, SQLError* error) -{ - v8::HandleScope handleScope; - - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); - if (v8Context.IsEmpty()) - return; - - v8::Context::Scope scope(v8Context); - - v8::Handle<v8::Value> argv[] = { - toV8(error) - }; - - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); - - bool callbackReturnValue = false; - invokeCallback(m_callback, 1, argv, callbackReturnValue); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.h b/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.h deleted file mode 100644 index 72e9e7a..0000000 --- a/WebCore/bindings/v8/custom/V8CustomSQLTransactionErrorCallback.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef V8CustomSQLTransactionErrorCallback_h -#define V8CustomSQLTransactionErrorCallback_h - -#if ENABLE(DATABASE) - -#include "SQLTransactionErrorCallback.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/Forward.h> - -namespace WebCore { - -class Frame; - -class V8CustomSQLTransactionErrorCallback : public SQLTransactionErrorCallback { -public: - static PassRefPtr<V8CustomSQLTransactionErrorCallback> create(v8::Local<v8::Value> value, Frame* frame) - { - ASSERT(value->IsObject()); - return adoptRef(new V8CustomSQLTransactionErrorCallback(value->ToObject(), frame)); - } - virtual ~V8CustomSQLTransactionErrorCallback(); - - virtual void handleEvent(ScriptExecutionContext*, SQLError*); - -private: - V8CustomSQLTransactionErrorCallback(v8::Local<v8::Object>, Frame*); - - v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; - WorldContextHandle m_worldContext; -}; - -} // namespace WebCore - -#endif - -#endif // V8CustomSQLTransactionErrorCallback_h diff --git a/WebCore/bindings/v8/custom/V8DatabaseCallback.cpp b/WebCore/bindings/v8/custom/V8DatabaseCallback.cpp deleted file mode 100644 index 088d89f..0000000 --- a/WebCore/bindings/v8/custom/V8DatabaseCallback.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2010, Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" - -#if ENABLE(DATABASE) - -#include "V8DatabaseCallback.h" - -#include "Frame.h" -#include "ScriptExecutionContext.h" -#include "V8CustomVoidCallback.h" -#include "V8Database.h" - -namespace WebCore { - -V8DatabaseCallback::V8DatabaseCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) - , m_worldContext(UseCurrentWorld) -{ -} - -V8DatabaseCallback::~V8DatabaseCallback() -{ - m_callback.Dispose(); -} - -void V8DatabaseCallback::handleEvent(ScriptExecutionContext* context, Database* database) -{ - v8::HandleScope handleScope; - - v8::Handle<v8::Context> v8Context = toV8Context(context, m_worldContext); - if (v8Context.IsEmpty()) - return; - - v8::Context::Scope scope(v8Context); - - v8::Handle<v8::Value> argv[] = { - toV8(database) - }; - - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); - - bool callbackReturnValue = false; - invokeCallback(m_callback, 1, argv, callbackReturnValue); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/v8/custom/V8DatabaseCallback.h b/WebCore/bindings/v8/custom/V8DatabaseCallback.h deleted file mode 100644 index 064a9a7..0000000 --- a/WebCore/bindings/v8/custom/V8DatabaseCallback.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef V8DatabaseCallback_h -#define V8DatabaseCallback_h - -#if ENABLE(DATABASE) - -#include "DatabaseCallback.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/Forward.h> - -namespace WebCore { - -class Frame; - -class V8DatabaseCallback : public DatabaseCallback { -public: - static PassRefPtr<V8DatabaseCallback> create(v8::Local<v8::Value> value, Frame* frame) - { - ASSERT(value->IsObject()); - return adoptRef(new V8DatabaseCallback(value->ToObject(), frame)); - } - virtual ~V8DatabaseCallback(); - - virtual void handleEvent(ScriptExecutionContext*, Database*); - -private: - V8DatabaseCallback(v8::Local<v8::Object>, Frame*); - - v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; - WorldContextHandle m_worldContext; -}; - -} // namespace WebCore - -#endif - -#endif // V8DatabaseCallback_h diff --git a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp index 9915d77..39e6632 100644 --- a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp @@ -35,8 +35,8 @@ #include "Database.h" #include "V8Binding.h" -#include "V8CustomSQLTransactionCallback.h" -#include "V8CustomSQLTransactionErrorCallback.h" +#include "V8SQLTransactionCallback.h" +#include "V8SQLTransactionErrorCallback.h" #include "V8CustomVoidCallback.h" #include "V8Proxy.h" @@ -58,20 +58,20 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg if (!frame) return v8::Undefined(); - RefPtr<V8CustomSQLTransactionCallback> callback; + RefPtr<V8SQLTransactionCallback> callback; if (args.Length() > 2) { if (!args[2]->IsObject()) return throwError("changeVersion transaction callback must be of valid type."); - callback = V8CustomSQLTransactionCallback::create(args[2], frame); + callback = V8SQLTransactionCallback::create(args[2], frame); } - RefPtr<V8CustomSQLTransactionErrorCallback> errorCallback; + RefPtr<V8SQLTransactionErrorCallback> errorCallback; if (args.Length() > 3) { if (!args[3]->IsObject()) return throwError("changeVersion error callback must be of valid type."); - errorCallback = V8CustomSQLTransactionErrorCallback::create(args[3], frame); + errorCallback = V8SQLTransactionErrorCallback::create(args[3], frame); } RefPtr<V8CustomVoidCallback> successCallback; @@ -101,14 +101,14 @@ static v8::Handle<v8::Value> createTransaction(const v8::Arguments& args, bool r if (!frame) return v8::Undefined(); - RefPtr<V8CustomSQLTransactionCallback> callback = V8CustomSQLTransactionCallback::create(args[0], frame); + RefPtr<V8SQLTransactionCallback> callback = V8SQLTransactionCallback::create(args[0], frame); - RefPtr<V8CustomSQLTransactionErrorCallback> errorCallback; + RefPtr<V8SQLTransactionErrorCallback> errorCallback; if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { if (!args[1]->IsObject()) return throwError("Transaction error callback must be of valid type."); - errorCallback = V8CustomSQLTransactionErrorCallback::create(args[1], frame); + errorCallback = V8SQLTransactionErrorCallback::create(args[1], frame); } RefPtr<V8CustomVoidCallback> successCallback; diff --git a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp index 0a9e8dd..786a96a 100644 --- a/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLFormElementCustom.cpp @@ -81,16 +81,4 @@ v8::Handle<v8::Value> V8HTMLFormElement::namedPropertyGetter(v8::Local<v8::Strin return toV8(collection); } -v8::Handle<v8::Value> V8HTMLFormElement::submitCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.HTMLFormElement.submit()"); - HTMLFormElement* form = V8HTMLFormElement::toNative(args.Holder()); - Frame* frame = V8Proxy::retrieveFrameForEnteredContext(); - if (!frame) - return v8::Undefined(); - - form->submit(frame); - return v8::Undefined(); -} - } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp index 4c091c8..c7cd54c 100644 --- a/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp +++ b/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp @@ -161,12 +161,6 @@ v8::Handle<v8::Value> V8InjectedScriptHost::currentCallFrameCallback(const v8::A INC_STATS("InjectedScriptHost.currentCallFrame()"); return toV8(ScriptDebugServer::shared().currentCallFrame()); } - -v8::Handle<v8::Value> V8InjectedScriptHost::isActivationCallback(const v8::Arguments& args) -{ - INC_STATS("InjectedScriptHost.isActivation()"); - return v8::Boolean::New(true); -} #endif #if ENABLE(DATABASE) diff --git a/WebCore/bindings/v8/custom/V8NodeFilterCustom.cpp b/WebCore/bindings/v8/custom/V8NodeFilterCustom.cpp deleted file mode 100644 index 7bb640b..0000000 --- a/WebCore/bindings/v8/custom/V8NodeFilterCustom.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "V8NodeFilter.h" - -#include "ExceptionCode.h" -#include "NodeFilter.h" - -#include "V8Binding.h" -#include "V8Proxy.h" - -namespace WebCore { - -v8::Handle<v8::Value> V8NodeFilter::acceptNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.NodeFilter.acceptNode()"); - return throwError(NOT_SUPPORTED_ERR); -} - -} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp b/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp deleted file mode 100644 index 728b3dc..0000000 --- a/WebCore/bindings/v8/custom/V8NodeIteratorCustom.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "V8NodeIterator.h" - -#include "NodeIterator.h" -#include "ScriptState.h" - -#include "V8Binding.h" -#include "V8Node.h" -#include "V8Proxy.h" - -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - -static inline v8::Handle<v8::Value> toV8(PassRefPtr<Node> object, ExceptionCode ec, ScriptState* state) -{ - if (ec) - return throwError(ec); - - if (state->hadException()) - return throwError(state->exception()); - - if (!object) - return v8::Null(); - - return toV8(object); -} - -v8::Handle<v8::Value> V8NodeIterator::nextNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.NodeIterator.nextNode()"); - NodeIterator* nodeIterator = V8NodeIterator::toNative(args.Holder()); - - ExceptionCode ec = 0; - EmptyScriptState state; - RefPtr<Node> result = nodeIterator->nextNode(&state, ec); - return toV8(result.release(), ec, &state); -} - -v8::Handle<v8::Value> V8NodeIterator::previousNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.NodeIterator.previousNode()"); - NodeIterator* nodeIterator = V8NodeIterator::toNative(args.Holder()); - - ExceptionCode ec = 0; - EmptyScriptState state; - RefPtr<Node> result = nodeIterator->previousNode(&state, ec); - return toV8(result.release(), ec, &state); -} - -} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp b/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp index cdb160d..51a57c0 100644 --- a/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp @@ -39,25 +39,6 @@ namespace WebCore { -v8::Handle<v8::Value> V8PopStateEvent::initPopStateEventCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.PopStateEvent.initPopStateEvent"); - - String typeArg = v8ValueToWebCoreString(args[0]); - bool canBubbleArg = args[1]->BooleanValue(); - bool cancelableArg = args[2]->BooleanValue(); - - bool didThrow = false; - RefPtr<SerializedScriptValue> stateArg = SerializedScriptValue::create(args[3], didThrow); - if (didThrow) - return v8::Undefined(); - - PopStateEvent* event = V8PopStateEvent::toNative(args.Holder()); - event->initPopStateEvent(typeArg, canBubbleArg, cancelableArg, stateArg.release()); - - return v8::Undefined(); -} - v8::Handle<v8::Value> V8PopStateEvent::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.PopStateEvent.state"); diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp index b7e7ff2..4e68b30 100644 --- a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp @@ -37,8 +37,8 @@ #include "Database.h" #include "SQLValue.h" #include "V8Binding.h" -#include "V8CustomSQLStatementCallback.h" -#include "V8CustomSQLStatementErrorCallback.h" +#include "V8SQLStatementCallback.h" +#include "V8SQLStatementErrorCallback.h" #include "V8Proxy.h" #include <wtf/Vector.h> @@ -105,7 +105,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& return throwError("Statement callback must be of valid type.", V8Proxy::TypeError); if (frame) - callback = V8CustomSQLStatementCallback::create(args[2], frame); + callback = V8SQLStatementCallback::create(args[2], frame); } RefPtr<SQLStatementErrorCallback> errorCallback; @@ -114,7 +114,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& return throwError("Statement error callback must be of valid type.", V8Proxy::TypeError); if (frame) - errorCallback = V8CustomSQLStatementErrorCallback::create(args[3], frame); + errorCallback = V8SQLStatementErrorCallback::create(args[3], frame); } ExceptionCode ec = 0; @@ -127,4 +127,3 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& } // namespace WebCore #endif - diff --git a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp b/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp deleted file mode 100644 index 37087df..0000000 --- a/WebCore/bindings/v8/custom/V8TreeWalkerCustom.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "V8TreeWalker.h" - -#include "Node.h" -#include "ScriptState.h" -#include "TreeWalker.h" - -#include "V8Binding.h" -#include "V8Node.h" -#include "V8Proxy.h" - -#include <wtf/PassRefPtr.h> -#include <wtf/RefPtr.h> - -namespace WebCore { - -static inline v8::Handle<v8::Value> toV8Object(PassRefPtr<Node> object, ScriptState* state) -{ - if (state->hadException()) - return throwError(state->exception()); - - if (!object) - return v8::Null(); - - return toV8(object); -} - -v8::Handle<v8::Value> V8TreeWalker::parentNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.parentNode()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->parentNode(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::firstChildCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.firstChild()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->firstChild(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::lastChildCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.lastChild()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->lastChild(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::nextNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.nextNode()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->nextNode(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::previousNodeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.previousNode()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->previousNode(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::nextSiblingCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.nextSibling()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->nextSibling(&state); - return toV8Object(result.release(), &state); -} - -v8::Handle<v8::Value> V8TreeWalker::previousSiblingCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.TreeWalker.previousSibling()"); - TreeWalker* treeWalker = V8TreeWalker::toNative(args.Holder()); - - EmptyScriptState state; - RefPtr<Node> result = treeWalker->previousSibling(&state); - return toV8Object(result.release(), &state); -} - -} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 1b8936d..75eff67 100644 --- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -105,80 +105,6 @@ static int* jsArrayToIntArray(v8::Handle<v8::Array> array, uint32_t len) return data; } -v8::Handle<v8::Value> V8WebGLRenderingContext::bufferDataCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLRenderingContext.bufferData()"); - - // Forms: - // * bufferData(GLenum target, WebGLArray data, GLenum usage); - // - Sets the buffer's data from the given WebGLArray - // * bufferData(GLenum target, GLsizeiptr size, GLenum usage); - // - Sets the size of the buffer to the given size in bytes - if (args.Length() != 3) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - bool ok; - int target = toInt32(args[0], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int usage = toInt32(args[2], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - if (args[1]->IsInt32()) { - int size = toInt32(args[1]); - ExceptionCode exceptionCode; - context->bufferData(target, size, usage, exceptionCode); - } else if (V8WebGLArray::HasInstance(args[1])) { - WebGLArray* array = V8WebGLArray::toNative(args[1]->ToObject()); - ExceptionCode exceptionCode; - context->bufferData(target, array, usage, exceptionCode); - } else { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8WebGLRenderingContext::bufferSubDataCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLRenderingContext.bufferSubData()"); - - // Forms: - // * bufferSubData(GLenum target, GLintptr offset, WebGLArray data); - if (args.Length() != 3) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - bool ok; - int target = toInt32(args[0], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int offset = toInt32(args[1], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - if (!V8WebGLArray::HasInstance(args[2])) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - WebGLArray* array = V8WebGLArray::toNative(args[2]->ToObject()); - ExceptionCode exceptionCode; - context->bufferSubData(target, offset, array, exceptionCode); - return v8::Undefined(); -} - static v8::Handle<v8::Value> toV8Object(const WebGLGetInfo& info) { switch (info.getType()) { @@ -443,290 +369,6 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getVertexAttribCallback(const v8: return getObjectParameter(args, kVertexAttrib); } -v8::Handle<v8::Value> V8WebGLRenderingContext::texImage2DCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLRenderingContext.texImage2D()"); - - // Currently supported forms: - // * void texImage2D(in GLenum target, in GLint level, - // in GLint internalformat, - // in GLsizei width, in GLsizei height, in GLint border, - // in GLenum format, in GLenum type, in WebGLArray pixels); - // * void texImage2D(in GLenum target, in GLint level, in ImageData pixels, - // [Optional] in GLboolean flipY, [Optional] in GLboolean premulitplyAlpha); - // * void texImage2D(in GLenum target, in GLint level, in HTMLImageElement image, - // [Optional] in GLboolean flipY, [Optional] in GLboolean premultiplyAlpha); - // * void texImage2D(in GLenum target, in GLint level, in HTMLCanvasElement image, - // [Optional] in GLboolean flipY, [Optional] in GLboolean premultiplyAlpha); - // * void texImage2D(in GLenum target, in GLint level, in HTMLVideoElement image, - // [Optional] in GLboolean flipY, [Optional] in GLboolean premultiplyAlpha); - if (args.Length() != 3 && - args.Length() != 4 && - args.Length() != 5 && - args.Length() != 9) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - bool ok; - int target = toInt32(args[0], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int level = toInt32(args[1], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - ExceptionCode ec = 0; - if (args.Length() == 3 || - args.Length() == 4 || - args.Length() == 5) { - bool flipY = false; - bool premultiplyAlpha = false; - if (args.Length() >= 4) - flipY = args[3]->BooleanValue(); - if (args.Length() >= 5) - premultiplyAlpha = args[4]->BooleanValue(); - - v8::Handle<v8::Value> arg = args[2]; - if (V8HTMLImageElement::HasInstance(arg)) { - HTMLImageElement* element = V8HTMLImageElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texImage2D(target, level, element, flipY, premultiplyAlpha, ec); - } else if (V8HTMLCanvasElement::HasInstance(arg)) { - HTMLCanvasElement* element = V8HTMLCanvasElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texImage2D(target, level, element, flipY, premultiplyAlpha, ec); - } else if(V8ImageData::HasInstance(arg)) { - ImageData* imageElement = V8ImageData::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texImage2D(target, level, imageElement, flipY, premultiplyAlpha, ec); - } else if (V8HTMLVideoElement::HasInstance(arg)) { - HTMLVideoElement* element = V8HTMLVideoElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texImage2D(target, level, element, flipY, premultiplyAlpha, ec); - } - else { - // FIXME: consider different / better exception type. - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - // Fall through - } else if (args.Length() == 9) { - int internalformat = toInt32(args[2], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int width = toInt32(args[3], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int height = toInt32(args[4], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int border = toInt32(args[5], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int format = toInt32(args[6], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int type = toInt32(args[7], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - v8::Handle<v8::Value> arg = args[8]; - if (!arg->IsObject()) - // Assume that the user is passing null for texture - context->texImage2D(target, - level, - internalformat, - width, - height, - border, - format, - type, - 0, - ec); - else if (V8WebGLArray::HasInstance(arg)) { - WebGLArray* array = V8WebGLArray::toNative(arg->ToObject()); - context->texImage2D(target, - level, - internalformat, - width, - height, - border, - format, - type, - array, - ec); - // Fall through - } else { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - } else { - ASSERT_NOT_REACHED(); - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - if (ec) { - V8Proxy::setDOMException(ec); - return v8::Handle<v8::Value>(); - } - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8WebGLRenderingContext::texSubImage2DCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLRenderingContext.texSubImage2D()"); - - // Currently supported forms: - // * void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, - // in GLsizei width, in GLsizei height, - // in GLenum format, in GLenum type, in WebGLArray pixels); - // * void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, - // in ImageData pixels, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); - // * void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, - // in HTMLImageElement image, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); - // * void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, - // in HTMLCanvasElement canvas, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); - // * void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, - // in HTMLVideoElement video, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); - - if (args.Length() != 5 && - args.Length() != 6 && - args.Length() != 7 && - args.Length() != 9) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - bool ok; - int target = toInt32(args[0], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int level = toInt32(args[1], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int xoff = toInt32(args[2], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int yoff = toInt32(args[3], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - - ExceptionCode ec = 0; - if (args.Length() == 5 || - args.Length() == 6 || - args.Length() == 7) { - bool flipY = false; - bool premultiplyAlpha = false; - if (args.Length() >= 6) - flipY = args[5]->BooleanValue(); - if (args.Length() >= 7) - premultiplyAlpha = args[6]->BooleanValue(); - - v8::Handle<v8::Value> arg = args[4]; - if (V8HTMLImageElement::HasInstance(arg)) { - HTMLImageElement* element = V8HTMLImageElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texSubImage2D(target, level, xoff, yoff, element, flipY, premultiplyAlpha, ec); - } else if (V8HTMLCanvasElement::HasInstance(arg)) { - HTMLCanvasElement* element = V8HTMLCanvasElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texSubImage2D(target, level, xoff, yoff, element, flipY, premultiplyAlpha, ec); - } else if(V8ImageData::HasInstance(arg)) { - ImageData* imageElement = V8ImageData::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texSubImage2D(target, level, xoff, yoff, imageElement, flipY, premultiplyAlpha, ec); - } else if (V8HTMLVideoElement::HasInstance(arg)) { - HTMLVideoElement* element = V8HTMLVideoElement::toNative(v8::Handle<v8::Object>::Cast(arg)); - context->texSubImage2D(target, level, xoff, yoff, element, flipY, premultiplyAlpha, ec); - } - else { - // FIXME: consider different / better exception type. - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - // Fall through - } else if (args.Length() == 9) { - int width = toInt32(args[4], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int height = toInt32(args[5], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int format = toInt32(args[6], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - int type = toInt32(args[7], ok); - if (!ok) { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - v8::Handle<v8::Value> arg = args[8]; - if (!arg->IsObject()) - // Assume that the user is passing null for texture - context->texSubImage2D(target, - level, - xoff, - yoff, - width, - height, - format, - type, - 0, - ec); - else if (V8WebGLArray::HasInstance(arg)) { - WebGLArray* array = V8WebGLArray::toNative(arg->ToObject()); - context->texSubImage2D(target, - level, - xoff, - yoff, - width, - height, - format, - type, - array, - ec); - // Fall through - } else { - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - } else { - ASSERT_NOT_REACHED(); - V8Proxy::setDOMException(SYNTAX_ERR); - return notHandledByInterceptor(); - } - if (ec) { - V8Proxy::setDOMException(ec); - return v8::Handle<v8::Value>(); - } - return v8::Undefined(); -} - enum FunctionToCall { kUniform1v, kUniform2v, kUniform3v, kUniform4v, kVertexAttrib1v, kVertexAttrib2v, kVertexAttrib3v, kVertexAttrib4v diff --git a/WebCore/bindings/v8/test/run_tests.py b/WebCore/bindings/v8/test/run_tests.py deleted file mode 100644 index e27d559..0000000 --- a/WebCore/bindings/v8/test/run_tests.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/python -# -# Copyright (C) 2010 Google Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -# This script generates h and cpp file for TestObj.idl using the V8 code -# generator. Please execute the script whenever changes are made to -# CodeGeneratorV8.pm, and submit the changes in V8TestObj.h/cpp in the same -# patch. This makes it easier to track and review changes in generated code. -# To execute, invoke: 'python run_tests.py' - -import os -import sys - - -def test(idlFilePath): - cmd = ['perl', '-w', - '-I../../scripts', - '../../scripts/generate-bindings.pl', - # idl include directories (path relative to generate-bindings.pl) - '--include .', - # place holder for defines (generate-bindings.pl requires it) - '--defines xxx', - '--generator V8', - '--outputDir .', - idlFilePath] - os.system(' '.join(cmd)) - - -def main(argv): - scriptDir = os.path.dirname(__file__) - os.chdir(scriptDir) - test('TestObj.idl') - - -if __name__ == '__main__': - sys.exit(main(sys.argv)) |