summaryrefslogtreecommitdiffstats
path: root/contrib/dom
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dom')
-rw-r--r--contrib/dom/idl/Attr.idl9
-rw-r--r--contrib/dom/idl/CDATASection.idl2
-rw-r--r--contrib/dom/idl/CharacterData.idl22
-rw-r--r--contrib/dom/idl/Comment.idl2
-rw-r--r--contrib/dom/idl/DOMException.idl27
-rw-r--r--contrib/dom/idl/DOMImplementation.idl14
-rw-r--r--contrib/dom/idl/Document.idl51
-rw-r--r--contrib/dom/idl/DocumentFragment.idl2
-rw-r--r--contrib/dom/idl/DocumentType.idl11
-rw-r--r--contrib/dom/idl/Element.idl41
-rw-r--r--contrib/dom/idl/Entity.idl5
-rw-r--r--contrib/dom/idl/EntityReference.idl2
-rw-r--r--contrib/dom/idl/NamedNodeMap.idl19
-rw-r--r--contrib/dom/idl/Node.idl59
-rw-r--r--contrib/dom/idl/NodeList.idl6
-rw-r--r--contrib/dom/idl/NodeSet.idl7
-rw-r--r--contrib/dom/idl/Notation.idl4
-rw-r--r--contrib/dom/idl/ProcessingInstruction.idl6
-rw-r--r--contrib/dom/idl/SCXMLEvent.idl18
-rw-r--r--contrib/dom/idl/Storage.idl8
-rw-r--r--contrib/dom/idl/Text.idl4
-rw-r--r--contrib/dom/idl/TypedArray.idl307
-rw-r--r--contrib/dom/idl/XPathNSResolver.idl.deact24
-rw-r--r--contrib/dom/idl/XPathResult.idl43
-rw-r--r--contrib/dom/scripts/CodeGenerator.pm752
-rw-r--r--contrib/dom/scripts/CodeGeneratorArabicaJSC.pm1154
-rw-r--r--contrib/dom/scripts/CodeGeneratorArabicaV8.pm1023
-rw-r--r--contrib/dom/scripts/CodeGeneratorArabicaV8.post3.14.pm1021
-rw-r--r--contrib/dom/scripts/IDLAttributes.txt126
-rw-r--r--contrib/dom/scripts/IDLParser.pm2456
-rw-r--r--contrib/dom/scripts/InFilesCompiler.pm296
-rw-r--r--contrib/dom/scripts/InFilesParser.pm154
-rwxr-xr-xcontrib/dom/scripts/generate-bindings.pl217
-rwxr-xr-xcontrib/dom/scripts/make_jsc.sh3
-rwxr-xr-xcontrib/dom/scripts/make_v8.sh3
-rw-r--r--contrib/dom/scripts/preprocessor.pm89
36 files changed, 0 insertions, 7987 deletions
diff --git a/contrib/dom/idl/Attr.idl b/contrib/dom/idl/Attr.idl
deleted file mode 100644
index 3964dd2..0000000
--- a/contrib/dom/idl/Attr.idl
+++ /dev/null
@@ -1,9 +0,0 @@
-interface Attr : Node {
- readonly attribute DOMString name;
- readonly attribute boolean specified;
- attribute DOMString value;
- // raises(DOMException) on setting
-
- // Introduced in DOM Level 2:
- readonly attribute Element ownerElement;
-};
diff --git a/contrib/dom/idl/CDATASection.idl b/contrib/dom/idl/CDATASection.idl
deleted file mode 100644
index fee476e..0000000
--- a/contrib/dom/idl/CDATASection.idl
+++ /dev/null
@@ -1,2 +0,0 @@
-interface CDATASection : Text {
-};
diff --git a/contrib/dom/idl/CharacterData.idl b/contrib/dom/idl/CharacterData.idl
deleted file mode 100644
index 893392b..0000000
--- a/contrib/dom/idl/CharacterData.idl
+++ /dev/null
@@ -1,22 +0,0 @@
-interface CharacterData : Node {
- attribute DOMString data;
- // raises(DOMException) on setting
- // raises(DOMException) on retrieval
-
- readonly attribute unsigned long length;
- DOMString substringData(in unsigned long offset,
- in unsigned long count)
- raises(DOMException);
- void appendData(in DOMString arg)
- raises(DOMException);
- void insertData(in unsigned long offset,
- in DOMString arg)
- raises(DOMException);
- void deleteData(in unsigned long offset,
- in unsigned long count)
- raises(DOMException);
- void replaceData(in unsigned long offset,
- in unsigned long count,
- in DOMString arg)
- raises(DOMException);
-};
diff --git a/contrib/dom/idl/Comment.idl b/contrib/dom/idl/Comment.idl
deleted file mode 100644
index 3497628..0000000
--- a/contrib/dom/idl/Comment.idl
+++ /dev/null
@@ -1,2 +0,0 @@
-interface Comment : CharacterData {
-};
diff --git a/contrib/dom/idl/DOMException.idl b/contrib/dom/idl/DOMException.idl
deleted file mode 100644
index 9c596e2..0000000
--- a/contrib/dom/idl/DOMException.idl
+++ /dev/null
@@ -1,27 +0,0 @@
-exception DOMException {
-
- // ExceptionCode
- const unsigned short INDEX_SIZE_ERR = 1;
- const unsigned short DOMSTRING_SIZE_ERR = 2;
- const unsigned short HIERARCHY_REQUEST_ERR = 3;
- const unsigned short WRONG_DOCUMENT_ERR = 4;
- const unsigned short INVALID_CHARACTER_ERR = 5;
- const unsigned short NO_DATA_ALLOWED_ERR = 6;
- const unsigned short NO_MODIFICATION_ALLOWED_ERR = 7;
- const unsigned short NOT_FOUND_ERR = 8;
- const unsigned short NOT_SUPPORTED_ERR = 9;
- const unsigned short INUSE_ATTRIBUTE_ERR = 10;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_STATE_ERR = 11;
- // Introduced in DOM Level 2:
- const unsigned short SYNTAX_ERR = 12;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_MODIFICATION_ERR = 13;
- // Introduced in DOM Level 2:
- const unsigned short NAMESPACE_ERR = 14;
- // Introduced in DOM Level 2:
- const unsigned short INVALID_ACCESS_ERR = 15;
-
- unsigned short code;
-
-};
diff --git a/contrib/dom/idl/DOMImplementation.idl b/contrib/dom/idl/DOMImplementation.idl
deleted file mode 100644
index a91db5d..0000000
--- a/contrib/dom/idl/DOMImplementation.idl
+++ /dev/null
@@ -1,14 +0,0 @@
-interface DOMImplementation {
- boolean hasFeature(in DOMString feature,
- in DOMString version);
- // Introduced in DOM Level 2:
- DocumentType createDocumentType(in DOMString qualifiedName,
- in DOMString publicId,
- in DOMString systemId)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Document createDocument(in DOMString namespaceURI,
- in DOMString qualifiedName,
- in DocumentType doctype)
- raises(DOMException);
-};
diff --git a/contrib/dom/idl/Document.idl b/contrib/dom/idl/Document.idl
deleted file mode 100644
index e80087a..0000000
--- a/contrib/dom/idl/Document.idl
+++ /dev/null
@@ -1,51 +0,0 @@
-interface Document : Node {
- readonly attribute DocumentType doctype;
- readonly attribute DOMImplementation implementation;
- readonly attribute Element documentElement;
- Element createElement(in DOMString tagName)
- raises(DOMException);
- DocumentFragment createDocumentFragment();
- Text createTextNode(in DOMString data);
- Comment createComment(in DOMString data);
- CDATASection createCDATASection(in DOMString data)
- raises(DOMException);
- ProcessingInstruction createProcessingInstruction(in DOMString target,
- in DOMString data)
- raises(DOMException);
- Attr createAttribute(in DOMString name)
- raises(DOMException);
- EntityReference createEntityReference(in DOMString name)
- raises(DOMException);
- NodeList getElementsByTagName(in DOMString tagname);
- // Introduced in DOM Level 2:
- Node importNode(in Node importedNode,
- in boolean deep)
- raises(DOMException);
- // Introduced in DOM Level 2:
- [Custom] Element createElementNS(in DOMString namespaceURI,
- in DOMString qualifiedName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- [Custom] Attr createAttributeNS(in DOMString namespaceURI,
- in DOMString qualifiedName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- NodeList getElementsByTagNameNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Element getElementById(in DOMString elementId);
-
- // DOM Level 3 XPath (XPathEvaluator interface)
-// XPathExpression createExpression(in DOMString expression,
-// in XPathNSResolver resolver)
-// raises(DOMException);
-// XPathNSResolver createNSResolver(in Node nodeResolver);
- [Custom] XPathResult evaluate(in DOMString expression,
- in Node contextNode)
-// in XPathNSResolver resolver,
-// in unsigned short type,
-// in XPathResult inResult)
- raises(DOMException);
- [CustomGetter] readonly attribute Storage localStorage;
-
-};
diff --git a/contrib/dom/idl/DocumentFragment.idl b/contrib/dom/idl/DocumentFragment.idl
deleted file mode 100644
index a05fe77..0000000
--- a/contrib/dom/idl/DocumentFragment.idl
+++ /dev/null
@@ -1,2 +0,0 @@
-interface DocumentFragment : Node {
-};
diff --git a/contrib/dom/idl/DocumentType.idl b/contrib/dom/idl/DocumentType.idl
deleted file mode 100644
index 9a9e45d..0000000
--- a/contrib/dom/idl/DocumentType.idl
+++ /dev/null
@@ -1,11 +0,0 @@
-interface DocumentType : Node {
- readonly attribute DOMString name;
- readonly attribute NamedNodeMap entities;
- readonly attribute NamedNodeMap notations;
- // Introduced in DOM Level 2:
- readonly attribute DOMString publicId;
- // Introduced in DOM Level 2:
- readonly attribute DOMString systemId;
- // Introduced in DOM Level 2:
- readonly attribute DOMString internalSubset;
-};
diff --git a/contrib/dom/idl/Element.idl b/contrib/dom/idl/Element.idl
deleted file mode 100644
index db175d2..0000000
--- a/contrib/dom/idl/Element.idl
+++ /dev/null
@@ -1,41 +0,0 @@
-interface Element : Node {
- readonly attribute DOMString tagName;
- DOMString getAttribute(in DOMString name);
- void setAttribute(in DOMString name,
- in DOMString value)
- raises(DOMException);
- void removeAttribute(in DOMString name)
- raises(DOMException);
- Attr getAttributeNode(in DOMString name);
- Attr setAttributeNode(in Attr newAttr)
- raises(DOMException);
- Attr removeAttributeNode(in Attr oldAttr)
- raises(DOMException);
- NodeList getElementsByTagName(in DOMString name);
- // Introduced in DOM Level 2:
- DOMString getAttributeNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- void setAttributeNS(in DOMString namespaceURI,
- in DOMString qualifiedName,
- in DOMString value)
- raises(DOMException);
- // Introduced in DOM Level 2:
- void removeAttributeNS(in DOMString namespaceURI,
- in DOMString localName)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Attr getAttributeNodeNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Attr setAttributeNodeNS(in Attr newAttr)
- raises(DOMException);
- // Introduced in DOM Level 2:
- NodeList getElementsByTagNameNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- boolean hasAttribute(in DOMString name);
- // Introduced in DOM Level 2:
- boolean hasAttributeNS(in DOMString namespaceURI,
- in DOMString localName);
-};
diff --git a/contrib/dom/idl/Entity.idl b/contrib/dom/idl/Entity.idl
deleted file mode 100644
index 8b91cb8..0000000
--- a/contrib/dom/idl/Entity.idl
+++ /dev/null
@@ -1,5 +0,0 @@
-interface Entity : Node {
- readonly attribute DOMString publicId;
- readonly attribute DOMString systemId;
- readonly attribute DOMString notationName;
-};
diff --git a/contrib/dom/idl/EntityReference.idl b/contrib/dom/idl/EntityReference.idl
deleted file mode 100644
index a211271..0000000
--- a/contrib/dom/idl/EntityReference.idl
+++ /dev/null
@@ -1,2 +0,0 @@
-interface EntityReference : Node {
-};
diff --git a/contrib/dom/idl/NamedNodeMap.idl b/contrib/dom/idl/NamedNodeMap.idl
deleted file mode 100644
index 6b4a38e..0000000
--- a/contrib/dom/idl/NamedNodeMap.idl
+++ /dev/null
@@ -1,19 +0,0 @@
-interface NamedNodeMap {
- Node getNamedItem(in DOMString name);
- Node setNamedItem(in Node arg)
- raises(DOMException);
- Node removeNamedItem(in DOMString name)
- raises(DOMException);
- Node item(in unsigned long index);
- readonly attribute unsigned long length;
- // Introduced in DOM Level 2:
- Node getNamedItemNS(in DOMString namespaceURI,
- in DOMString localName);
- // Introduced in DOM Level 2:
- Node setNamedItemNS(in Node arg)
- raises(DOMException);
- // Introduced in DOM Level 2:
- Node removeNamedItemNS(in DOMString namespaceURI,
- in DOMString localName)
- raises(DOMException);
-};
diff --git a/contrib/dom/idl/Node.idl b/contrib/dom/idl/Node.idl
deleted file mode 100644
index f819441..0000000
--- a/contrib/dom/idl/Node.idl
+++ /dev/null
@@ -1,59 +0,0 @@
-interface Node {
-
- // NodeType
- const unsigned short ELEMENT_NODE = 1;
- const unsigned short ATTRIBUTE_NODE = 2;
- const unsigned short TEXT_NODE = 3;
- const unsigned short CDATA_SECTION_NODE = 4;
- const unsigned short ENTITY_REFERENCE_NODE = 5;
- const unsigned short ENTITY_NODE = 6;
- const unsigned short PROCESSING_INSTRUCTION_NODE = 7;
- const unsigned short COMMENT_NODE = 8;
- const unsigned short DOCUMENT_NODE = 9;
- const unsigned short DOCUMENT_TYPE_NODE = 10;
- const unsigned short DOCUMENT_FRAGMENT_NODE = 11;
- const unsigned short NOTATION_NODE = 12;
-
- readonly attribute DOMString nodeName;
- attribute DOMString nodeValue;
- // raises(DOMException) on setting
- // raises(DOMException) on retrieval
-
- readonly attribute unsigned short nodeType;
- readonly attribute Node parentNode;
- readonly attribute NodeList childNodes;
- readonly attribute Node firstChild;
- readonly attribute Node lastChild;
- readonly attribute Node previousSibling;
- readonly attribute Node nextSibling;
- [CustomGetter] readonly attribute NamedNodeMap attributes;
- // Modified in DOM Level 2:
- readonly attribute Document ownerDocument;
- Node insertBefore(in Node newChild,
- in Node refChild)
- raises(DOMException);
- Node replaceChild(in Node newChild,
- in Node oldChild)
- raises(DOMException);
- Node removeChild(in Node oldChild)
- raises(DOMException);
- Node appendChild(in Node newChild)
- raises(DOMException);
- boolean hasChildNodes();
- Node cloneNode(in boolean deep);
- // Modified in DOM Level 2:
- void normalize();
- // Introduced in DOM Level 2:
- boolean isSupported(in DOMString feature,
- in DOMString version);
- // Introduced in DOM Level 2:
- readonly attribute DOMString namespaceURI;
- // Introduced in DOM Level 2:
- attribute DOMString prefix;
- // raises(DOMException) on setting
-
- // Introduced in DOM Level 2:
- readonly attribute DOMString localName;
- // Introduced in DOM Level 2:
- boolean hasAttributes();
-};
diff --git a/contrib/dom/idl/NodeList.idl b/contrib/dom/idl/NodeList.idl
deleted file mode 100644
index cef2f90..0000000
--- a/contrib/dom/idl/NodeList.idl
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- CustomIndexedGetter
-] interface NodeList {
- Node item(in unsigned long index);
- readonly attribute unsigned long length;
-};
diff --git a/contrib/dom/idl/NodeSet.idl b/contrib/dom/idl/NodeSet.idl
deleted file mode 100644
index 4a32eaf..0000000
--- a/contrib/dom/idl/NodeSet.idl
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- CustomIndexedGetter
-] interface NodeSet {
- void toDocumentOrder();
- readonly attribute unsigned long size;
- readonly attribute boolean empty;
-};
diff --git a/contrib/dom/idl/Notation.idl b/contrib/dom/idl/Notation.idl
deleted file mode 100644
index 2d8666e..0000000
--- a/contrib/dom/idl/Notation.idl
+++ /dev/null
@@ -1,4 +0,0 @@
-interface Notation : Node {
- readonly attribute DOMString publicId;
- readonly attribute DOMString systemId;
-};
diff --git a/contrib/dom/idl/ProcessingInstruction.idl b/contrib/dom/idl/ProcessingInstruction.idl
deleted file mode 100644
index 3e90159..0000000
--- a/contrib/dom/idl/ProcessingInstruction.idl
+++ /dev/null
@@ -1,6 +0,0 @@
-interface ProcessingInstruction : Node {
- readonly attribute DOMString target;
- attribute DOMString data;
- // raises(DOMException) on setting
-
-};
diff --git a/contrib/dom/idl/SCXMLEvent.idl b/contrib/dom/idl/SCXMLEvent.idl
deleted file mode 100644
index 67f5070..0000000
--- a/contrib/dom/idl/SCXMLEvent.idl
+++ /dev/null
@@ -1,18 +0,0 @@
-[
- AttributesArePublic
-] interface SCXMLEvent {
-
- // NodeType
- const unsigned short INTERNAL = 1;
- const unsigned short EXTERNAL = 2;
- const unsigned short PLATFORM = 3;
-
- [CustomGetter, EmptyAsNull] readonly attribute DOMString type;
- readonly attribute DOMString name;
- [EmptyAsNull] readonly attribute DOMString origin;
- [EmptyAsNull] readonly attribute DOMString origintype;
- [EmptyAsNull] readonly attribute DOMString raw;
- readonly attribute Node dom;
- [CustomGetter] readonly attribute DOMString sendid;
- [EmptyAsNull] readonly attribute DOMString invokeid;
-};
diff --git a/contrib/dom/idl/Storage.idl b/contrib/dom/idl/Storage.idl
deleted file mode 100644
index e709184..0000000
--- a/contrib/dom/idl/Storage.idl
+++ /dev/null
@@ -1,8 +0,0 @@
-[DontDestroyWrapped] interface Storage {
- readonly attribute unsigned long length;
- DOMString key(unsigned long index);
- getter DOMString getItem(DOMString key);
- setter creator void setItem(DOMString key, DOMString value);
- deleter void removeItem(DOMString key);
- void clear();
-};
diff --git a/contrib/dom/idl/Text.idl b/contrib/dom/idl/Text.idl
deleted file mode 100644
index 159f3eb..0000000
--- a/contrib/dom/idl/Text.idl
+++ /dev/null
@@ -1,4 +0,0 @@
-interface Text : CharacterData {
- Text splitText(in unsigned long offset)
- raises(DOMException);
-};
diff --git a/contrib/dom/idl/TypedArray.idl b/contrib/dom/idl/TypedArray.idl
deleted file mode 100644
index f288361..0000000
--- a/contrib/dom/idl/TypedArray.idl
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * typedarray.idl
- *
- * TypedArray IDL definitions scraped from the Khronos specification.
- *
- * Original Khronos Working Draft:
- *
- * https://www.khronos.org/registry/typedarray/specs/latest/
- */
-
-[
- Constructor(unsigned long length)
-]
-interface ArrayBuffer {
- readonly attribute unsigned long byteLength;
- attribute DOMString mimeType;
- DOMString md5();
- DOMString base64();
- ArrayBuffer slice(long begin, optional long end);
- static boolean isView(any value);
-};
-
-[NoInterfaceObject]
-interface ArrayBufferView {
- readonly attribute ArrayBuffer buffer;
- readonly attribute unsigned long byteOffset;
- readonly attribute unsigned long byteLength;
-};
-
-
-// The 'byte' type does not currently exist in Web IDL.
-// In this IDL, it should be a signed 8 bit type.
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Int8Array array),
- Constructor(byte[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Int8Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 1;
-
- readonly attribute unsigned long length;
-
- getter byte get(unsigned long index);
- setter void set(unsigned long index, byte value);
- void set(Int8Array array, optional unsigned long offset);
- void set(byte[] array, optional unsigned long offset);
- Int8Array subarray(long start, optional long end);
-};
-Int8Array implements ArrayBufferView;
-
-
-// The 'unsigned byte' type does not currently exist in Web IDL, though
-// 'octet' is equivalent.
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Uint8Array array),
- Constructor(octet[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Uint8Array : ArrayBufferView{
- const long BYTES_PER_ELEMENT = 1;
-
- readonly attribute unsigned long length;
-
- getter octet get(unsigned long index);
- setter void set(unsigned long index, octet value);
- void set(Uint8Array array, optional unsigned long offset);
- void set(octet[] array, optional unsigned long offset);
- Uint8Array subarray(long start, optional long end);
-};
-Uint8Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Uint8ClampedArray array),
- Constructor(octet[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Uint8ClampedArray : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 1;
-
- readonly attribute unsigned long length;
-
- getter octet get(unsigned long index);
- setter void set(unsigned long index, [Clamp] octet value);
- void set(Uint8ClampedArray array, optional unsigned long offset);
- void set(octet[] array, optional unsigned long offset);
- Uint8ClampedArray subarray(long start, optional long end);
-};
-Uint8ClampedArray implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Int16Array array),
- Constructor(short[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Int16Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 2;
-
- readonly attribute unsigned long length;
-
- getter short get(unsigned long index);
- setter void set(unsigned long index, short value);
- void set(Int16Array array, optional unsigned long offset);
- void set(short[] array, optional unsigned long offset);
- Int16Array subarray(long start, optional long end);
-};
-Int16Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Uint16Array array),
- Constructor(unsigned short[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Uint16Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 2;
-
- readonly attribute unsigned long length;
-
- getter unsigned short get(unsigned long index);
- setter void set(unsigned long index, unsigned short value);
- void set(Uint16Array array, optional unsigned long offset);
- void set(unsigned short[] array, optional unsigned long offset);
- Uint16Array subarray(long start, optional long end);
-};
-Uint16Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Int32Array array),
- Constructor(long[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Int32Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 4;
-
- readonly attribute unsigned long length;
-
- getter long get(unsigned long index);
- setter void set(unsigned long index, long value);
- void set(Int32Array array, optional unsigned long offset);
- void set(long[] array, optional unsigned long offset);
- Int32Array subarray(long start, optional long end);
-};
-Int32Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Uint32Array array),
- Constructor(unsigned long[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Uint32Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 4;
-
- readonly attribute unsigned long length;
-
- getter unsigned long get(unsigned long index);
- setter void set(unsigned long index, unsigned long value);
- void set(Uint32Array array, optional unsigned long offset);
- void set(unsigned long[] array, optional unsigned long offset);
- Uint32Array subarray(long start, optional long end);
-};
-Uint32Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Float32Array array),
- Constructor(float[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Float32Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 4;
-
- readonly attribute unsigned long length;
-
- getter float get(unsigned long index);
- setter void set(unsigned long index, float value);
- void set(Float32Array array, optional unsigned long offset);
- void set(float[] array, optional unsigned long offset);
- Float32Array subarray(long start, optional long end);
-};
-Float32Array implements ArrayBufferView;
-
-
-[
- CustomIndexedGetter,
- CustomIndexedSetter,
- Constructor(unsigned long length),
- Constructor(Float64Array array),
- Constructor(double[] array),
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset, optional unsigned long length)
-]
-interface Float64Array : ArrayBufferView {
- const long BYTES_PER_ELEMENT = 8;
-
- readonly attribute unsigned long length;
-
- getter double get(unsigned long index);
- setter void set(unsigned long index, double value);
- void set(Float64Array array, optional unsigned long offset);
- void set(double[] array, optional unsigned long offset);
- Float64Array subarray(long start, optional long end);
-};
-Float64Array implements ArrayBufferView;
-
-
-[
- Constructor(ArrayBuffer buffer,
- optional unsigned long byteOffset,
- optional unsigned long byteLength)
-]
-interface DataView : ArrayBufferView{
- // Gets the value of the given type at the specified byte offset
- // from the start of the view. There is no alignment constraint;
- // multi-byte values may be fetched from any offset.
- //
- // For multi-byte values, the optional littleEndian argument
- // indicates whether a big-endian or little-endian value should be
- // read. If false or undefined, a big-endian value is read.
- //
- // These methods raise an INDEX_SIZE_ERR exception if they would read
- // beyond the end of the view.
- byte getInt8(unsigned long byteOffset);
- octet getUint8(unsigned long byteOffset);
- short getInt16(unsigned long byteOffset,
- optional boolean littleEndian);
- unsigned short getUint16(unsigned long byteOffset,
- optional boolean littleEndian);
- long getInt32(unsigned long byteOffset,
- optional boolean littleEndian);
- unsigned long getUint32(unsigned long byteOffset,
- optional boolean littleEndian);
- float getFloat32(unsigned long byteOffset,
- optional boolean littleEndian);
- double getFloat64(unsigned long byteOffset,
- optional boolean littleEndian);
-
- // Stores a value of the given type at the specified byte offset
- // from the start of the view. There is no alignment constraint;
- // multi-byte values may be stored at any offset.
- //
- // For multi-byte values, the optional littleEndian argument
- // indicates whether the value should be stored in big-endian or
- // little-endian byte order. If false or undefined, the value is
- // stored in big-endian byte order.
- //
- // These methods throw exceptions if they would write beyond the end
- // of the view.
- void setInt8(unsigned long byteOffset,
- byte value);
- void setUint8(unsigned long byteOffset,
- octet value);
- void setInt16(unsigned long byteOffset,
- short value,
- optional boolean littleEndian);
- void setUint16(unsigned long byteOffset,
- unsigned short value,
- optional boolean littleEndian);
- void setInt32(unsigned long byteOffset,
- long value,
- optional boolean littleEndian);
- void setUint32(unsigned long byteOffset,
- unsigned long value,
- optional boolean littleEndian);
- void setFloat32(unsigned long byteOffset,
- float value,
- optional boolean littleEndian);
- void setFloat64(unsigned long byteOffset,
- double value,
- optional boolean littleEndian);
-};
-DataView implements ArrayBufferView; \ No newline at end of file
diff --git a/contrib/dom/idl/XPathNSResolver.idl.deact b/contrib/dom/idl/XPathNSResolver.idl.deact
deleted file mode 100644
index 3f52acb..0000000
--- a/contrib/dom/idl/XPathNSResolver.idl.deact
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
- *
- * 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.
- */
-
-interface XPathNSResolver {
- DOMString lookupNamespaceURI(in DOMString prefix);
-};
-
diff --git a/contrib/dom/idl/XPathResult.idl b/contrib/dom/idl/XPathResult.idl
deleted file mode 100644
index 869207f..0000000
--- a/contrib/dom/idl/XPathResult.idl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, Inc.
- *
- * 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.
- */
-
-interface XPathResult {
-
- readonly attribute double numberValue
- getter raises (DOMException);
-
- readonly attribute DOMString stringValue
- getter raises (DOMException);
-
- readonly attribute boolean booleanValue
- getter raises (DOMException);
-
- [CustomGetter] readonly attribute Node singleNodeValue
- getter raises (DOMException);
-
- NodeSet asNodeSet()
- raises (DOMException);
- boolean asBool()
- raises (DOMException);
- DOMString asString()
- raises (DOMException);
- double asNumber()
- raises (DOMException);
-};
-
diff --git a/contrib/dom/scripts/CodeGenerator.pm b/contrib/dom/scripts/CodeGenerator.pm
deleted file mode 100644
index fba0093..0000000
--- a/contrib/dom/scripts/CodeGenerator.pm
+++ /dev/null
@@ -1,752 +0,0 @@
-#
-# WebKit IDL parser
-#
-# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
-# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
-# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
-# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
-# Copyright (C) Research In Motion Limited 2010. All rights reserved.
-#
-# 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.
-#
-
-package CodeGenerator;
-
-use strict;
-
-use File::Find;
-use Data::Dumper;
-use Carp qw/longmess cluck confess/;
-
-my $useDocument = "";
-my $useGenerator = "";
-my $useOutputDir = "";
-my $useOutputHeadersDir = "";
-my $useDirectories = "";
-my $useLayerOnTop = 0;
-my $preprocessor;
-my $writeDependencies = 0;
-my $defines = "";
-my $targetIdlFilePath = "";
-
-my $codeGenerator = 0;
-
-my $verbose = 0;
-
-my %numericTypeHash = ("int" => 1, "short" => 1, "long" => 1, "long long" => 1,
- "unsigned int" => 1, "unsigned short" => 1,
- "unsigned long" => 1, "unsigned long long" => 1,
- "float" => 1, "double" => 1);
-
-my %primitiveTypeHash = ( "boolean" => 1, "void" => 1, "Date" => 1);
-
-my %stringTypeHash = ("DOMString" => 1, "AtomicString" => 1);
-
-my %nonPointerTypeHash = ("DOMTimeStamp" => 1, "CompareHow" => 1);
-
-my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1,
- "SVGAnimatedEnumeration" => 1, "SVGAnimatedInteger" => 1,
- "SVGAnimatedLength" => 1, "SVGAnimatedLengthList" => 1,
- "SVGAnimatedNumber" => 1, "SVGAnimatedNumberList" => 1,
- "SVGAnimatedPreserveAspectRatio" => 1,
- "SVGAnimatedRect" => 1, "SVGAnimatedString" => 1,
- "SVGAnimatedTransformList" => 1);
-
-my %svgAttributesInHTMLHash = ("class" => 1, "id" => 1, "onabort" => 1, "onclick" => 1,
- "onerror" => 1, "onload" => 1, "onmousedown" => 1,
- "onmousemove" => 1, "onmouseout" => 1, "onmouseover" => 1,
- "onmouseup" => 1, "onresize" => 1, "onscroll" => 1,
- "onunload" => 1);
-
-my %svgTypeNeedingTearOff = (
- "SVGAngle" => "SVGPropertyTearOff<SVGAngle>",
- "SVGLength" => "SVGPropertyTearOff<SVGLength>",
- "SVGLengthList" => "SVGListPropertyTearOff<SVGLengthList>",
- "SVGMatrix" => "SVGPropertyTearOff<SVGMatrix>",
- "SVGNumber" => "SVGPropertyTearOff<float>",
- "SVGNumberList" => "SVGListPropertyTearOff<SVGNumberList>",
- "SVGPathSegList" => "SVGPathSegListPropertyTearOff",
- "SVGPoint" => "SVGPropertyTearOff<FloatPoint>",
- "SVGPointList" => "SVGListPropertyTearOff<SVGPointList>",
- "SVGPreserveAspectRatio" => "SVGPropertyTearOff<SVGPreserveAspectRatio>",
- "SVGRect" => "SVGPropertyTearOff<FloatRect>",
- "SVGStringList" => "SVGStaticListPropertyTearOff<SVGStringList>",
- "SVGTransform" => "SVGPropertyTearOff<SVGTransform>",
- "SVGTransformList" => "SVGTransformListPropertyTearOff"
-);
-
-my %svgTypeWithWritablePropertiesNeedingTearOff = (
- "SVGPoint" => 1,
- "SVGMatrix" => 1
-);
-
-# Cache of IDL file pathnames.
-my $idlFiles;
-
-# Default constructor
-sub new
-{
- my $object = shift;
- my $reference = { };
-
- $useDirectories = shift;
- $useGenerator = shift;
- $useOutputDir = shift;
- $useOutputHeadersDir = shift;
- $useLayerOnTop = shift;
- $preprocessor = shift;
- $writeDependencies = shift;
- $verbose = shift;
- $targetIdlFilePath = shift;
-
- bless($reference, $object);
- return $reference;
-}
-
-sub ProcessDocument
-{
- my $object = shift;
- $useDocument = shift;
- $defines = shift;
-
- my $ifaceName = "CodeGenerator" . $useGenerator;
- require $ifaceName . ".pm";
-
- # Dynamically load external code generation perl module
- $codeGenerator = $ifaceName->new($object, $useLayerOnTop, $preprocessor, $writeDependencies, $verbose, $targetIdlFilePath);
- unless (defined($codeGenerator)) {
- my $interfaces = $useDocument->interfaces;
- foreach my $interface (@$interfaces) {
- print "Skipping $useGenerator code generation for IDL interface \"" . $interface->name . "\".\n" if $verbose;
- }
- return;
- }
-
- my $interfaces = $useDocument->interfaces;
- foreach my $interface (@$interfaces) {
- print "Generating $useGenerator bindings code for IDL interface \"" . $interface->name . "\"...\n" if $verbose;
- $codeGenerator->GenerateInterface($interface, $defines);
- $codeGenerator->WriteData($interface, $useOutputDir, $useOutputHeadersDir);
- }
-}
-
-sub FileNamePrefix
-{
- my $object = shift;
-
- my $ifaceName = "CodeGenerator" . $useGenerator;
- require $ifaceName . ".pm";
-
- # Dynamically load external code generation perl module
- $codeGenerator = $ifaceName->new($object, $useLayerOnTop, $preprocessor, $writeDependencies, $verbose);
- return $codeGenerator->FileNamePrefix();
-}
-
-sub UpdateFile
-{
- my $object = shift;
- my $fileName = shift;
- my $contents = shift;
-
- open FH, "> $fileName" or die "Couldn't open $fileName: $!\n";
- print FH $contents;
- close FH;
-}
-
-sub ForAllParents
-{
- my $object = shift;
- my $interface = shift;
- my $beforeRecursion = shift;
- my $afterRecursion = shift;
- my $parentsOnly = shift;
-
- my $recurse;
- $recurse = sub {
- my $currentInterface = shift;
-
- for (@{$currentInterface->parents}) {
- my $interfaceName = $_;
- my $parentInterface = $object->ParseInterface($interfaceName, $parentsOnly);
-
- if ($beforeRecursion) {
- &$beforeRecursion($parentInterface) eq 'prune' and next;
- }
- &$recurse($parentInterface);
- &$afterRecursion($parentInterface) if $afterRecursion;
- }
- };
-
- &$recurse($interface);
-}
-
-sub AddMethodsConstantsAndAttributesFromParentInterfaces
-{
- # Add to $interface all of its inherited interface members, except for those
- # inherited through $interface's first listed parent. If an array reference
- # is passed in as $parents, the names of all ancestor interfaces visited
- # will be appended to the array. If $collectDirectParents is true, then
- # even the names of $interface's first listed parent and its ancestors will
- # be appended to $parents.
-
- my $object = shift;
- my $interface = shift;
- my $parents = shift;
- my $collectDirectParents = shift;
-
- my $first = 1;
-
- $object->ForAllParents($interface, sub {
- my $currentInterface = shift;
-
- if ($first) {
- # Ignore first parent class, already handled by the generation itself.
- $first = 0;
-
- if ($collectDirectParents) {
- # Just collect the names of the direct ancestor interfaces,
- # if necessary.
- push(@$parents, $currentInterface->name);
- $object->ForAllParents($currentInterface, sub {
- my $currentInterface = shift;
- push(@$parents, $currentInterface->name);
- }, undef, 1);
- }
-
- # Prune the recursion here.
- return 'prune';
- }
-
- # Collect the name of this additional parent.
- push(@$parents, $currentInterface->name) if $parents;
-
- print " | |> -> Inheriting "
- . @{$currentInterface->constants} . " constants, "
- . @{$currentInterface->functions} . " functions, "
- . @{$currentInterface->attributes} . " attributes...\n | |>\n" if $verbose;
-
- # Add this parent's members to $interface.
- push(@{$interface->constants}, @{$currentInterface->constants});
- push(@{$interface->functions}, @{$currentInterface->functions});
- push(@{$interface->attributes}, @{$currentInterface->attributes});
- });
-}
-
-sub FindSuperMethod
-{
- my ($object, $interface, $functionName) = @_;
- my $indexer;
- $object->ForAllParents($interface, undef, sub {
- my $currentInterface = shift;
- foreach my $function (@{$currentInterface->functions}) {
- if ($function->signature->name eq $functionName) {
- $indexer = $function->signature;
- return 'prune';
- }
- }
- });
- return $indexer;
-}
-
-sub IDLFileForInterface
-{
- my $object = shift;
- my $interfaceName = shift;
-
- unless ($idlFiles) {
- my $sourceRoot = $ENV{SOURCE_ROOT};
- my @directories = map { $_ = "$sourceRoot/$_" if $sourceRoot && -d "$sourceRoot/$_"; $_ } @$useDirectories;
-
- $idlFiles = { };
-
- my $wanted = sub {
- $idlFiles->{$1} = $File::Find::name if /^([A-Z].*)\.idl$/;
- $File::Find::prune = 1 if /^\../;
- };
- find($wanted, @directories);
- $idlFiles->{"ArrayBufferView"} = "../idl/TypedArray.idl"
- }
-
- # print Dumper($object);
- # print Dumper($interfaceName);
-
- return $idlFiles->{$interfaceName};
-}
-
-sub ParseInterface
-{
- my $object = shift;
- my $interfaceName = shift;
- my $parentsOnly = shift;
-
- return undef if $interfaceName eq 'Object';
-
- # Step #1: Find the IDL file associated with 'interface'
- my $filename = $object->IDLFileForInterface($interfaceName)
- or confess("Could NOT find IDL file for interface \"$interfaceName\"!\n");
-
- print " | |> Parsing parent IDL \"$filename\" for interface \"$interfaceName\"\n" if $verbose;
-
- # Step #2: Parse the found IDL file (in quiet mode).
- my $parser = IDLParser->new(1);
- my $document = $parser->Parse($filename, $defines, $preprocessor, $parentsOnly);
-
- foreach my $interface (@{$document->interfaces}) {
- return $interface if $interface->name eq $interfaceName;
- }
-
- die("Could NOT find interface definition for $interfaceName in $filename");
-}
-
-# Helpers for all CodeGenerator***.pm modules
-
-sub SkipIncludeHeader
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $primitiveTypeHash{$type};
- return 1 if $numericTypeHash{$type};
- return 1 if $type eq "String";
-
- # Special case: SVGPoint.h / SVGNumber.h do not exist.
- return 1 if $type eq "SVGPoint" or $type eq "SVGNumber";
- return 0;
-}
-
-sub IsArrayType
-{
- my $object = shift;
- my $type = shift;
- # FIXME: Add proper support for T[], T[]?, sequence<T>.
- return $type =~ m/\[\]$/;
-}
-
-sub IsConstructorTemplate
-{
- my $object = shift;
- my $interface = shift;
- my $template = shift;
-
- return $interface->extendedAttributes->{"ConstructorTemplate"} && $interface->extendedAttributes->{"ConstructorTemplate"} eq $template;
-}
-
-sub IsPrimitiveType
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $primitiveTypeHash{$type};
- return 1 if $numericTypeHash{$type};
- return 0;
-}
-
-sub IsStringType
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $stringTypeHash{$type};
- return 0;
-}
-
-sub IsNonPointerType
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $nonPointerTypeHash{$type} or $primitiveTypeHash{$type} or $numericTypeHash{$type};
- return 0;
-}
-
-sub IsSVGTypeNeedingTearOff
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if exists $svgTypeNeedingTearOff{$type};
- return 0;
-}
-
-sub IsSVGTypeWithWritablePropertiesNeedingTearOff
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $svgTypeWithWritablePropertiesNeedingTearOff{$type};
- return 0;
-}
-
-sub IsTypedArrayType
-{
- my $object = shift;
- my $type = shift;
- return 1 if (($type eq "ArrayBuffer") or ($type eq "ArrayBufferView"));
- return 1 if (($type eq "Uint8Array") or ($type eq "Uint8ClampedArray") or ($type eq "Uint16Array") or ($type eq "Uint32Array"));
- return 1 if (($type eq "Int8Array") or ($type eq "Int16Array") or ($type eq "Int32Array"));
- return 1 if (($type eq "Float32Array") or ($type eq "Float64Array"));
- return 0;
-}
-
-sub IsRefPtrType
-{
- my $object = shift;
- my $type = shift;
-
- return 0 if $object->IsPrimitiveType($type);
- return 0 if $type eq "DOMString";
-
- return 1;
-}
-
-sub GetSVGTypeNeedingTearOff
-{
- my $object = shift;
- my $type = shift;
-
- return $svgTypeNeedingTearOff{$type} if exists $svgTypeNeedingTearOff{$type};
- return undef;
-}
-
-sub GetSVGWrappedTypeNeedingTearOff
-{
- my $object = shift;
- my $type = shift;
-
- my $svgTypeNeedingTearOff = $object->GetSVGTypeNeedingTearOff($type);
- return $svgTypeNeedingTearOff if not $svgTypeNeedingTearOff;
-
- if ($svgTypeNeedingTearOff =~ /SVGPropertyTearOff/) {
- $svgTypeNeedingTearOff =~ s/SVGPropertyTearOff<//;
- } elsif ($svgTypeNeedingTearOff =~ /SVGListPropertyTearOff/) {
- $svgTypeNeedingTearOff =~ s/SVGListPropertyTearOff<//;
- } elsif ($svgTypeNeedingTearOff =~ /SVGStaticListPropertyTearOff/) {
- $svgTypeNeedingTearOff =~ s/SVGStaticListPropertyTearOff<//;
- } elsif ($svgTypeNeedingTearOff =~ /SVGTransformListPropertyTearOff/) {
- $svgTypeNeedingTearOff =~ s/SVGTransformListPropertyTearOff<//;
- }
-
- $svgTypeNeedingTearOff =~ s/>//;
- return $svgTypeNeedingTearOff;
-}
-
-sub IsSVGAnimatedType
-{
- my $object = shift;
- my $type = shift;
-
- return 1 if $svgAnimatedTypeHash{$type};
- return 0;
-}
-
-sub GetSequenceType
-{
- my $object = shift;
- my $type = shift;
-
- return $1 if $type =~ /^sequence<([\w\d_\s]+)>.*/;
- return "";
-}
-
-sub GetArrayType
-{
- my $object = shift;
- my $type = shift;
-
- return $1 if $type =~ /^([\w\d_\s]+)\[\]/;
- return "";
-}
-
-sub AssertNotSequenceType
-{
- my $object = shift;
- my $type = shift;
- die "Sequences must not be used as the type of an attribute, constant or exception field." if $object->GetSequenceType($type);
-}
-
-# Uppercase the first letter while respecting WebKit style guidelines.
-# E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
-sub WK_ucfirst
-{
- my ($object, $param) = @_;
- my $ret = ucfirst($param);
- $ret =~ s/Xml/XML/ if $ret =~ /^Xml[^a-z]/;
-
- return $ret;
-}
-
-# Lowercase the first letter while respecting WebKit style guidelines.
-# URL becomes url, but SetURL becomes setURL.
-sub WK_lcfirst
-{
- my ($object, $param) = @_;
- my $ret = lcfirst($param);
- $ret =~ s/hTML/html/ if $ret =~ /^hTML/;
- $ret =~ s/uRL/url/ if $ret =~ /^uRL/;
- $ret =~ s/jS/js/ if $ret =~ /^jS/;
- $ret =~ s/xML/xml/ if $ret =~ /^xML/;
- $ret =~ s/xSLT/xslt/ if $ret =~ /^xSLT/;
-
- # For HTML5 FileSystem API Flags attributes.
- # (create is widely used to instantiate an object and must be avoided.)
- $ret =~ s/^create/isCreate/ if $ret =~ /^create$/;
- $ret =~ s/^exclusive/isExclusive/ if $ret =~ /^exclusive$/;
-
- return $ret;
-}
-
-# Return the C++ namespace that a given attribute name string is defined in.
-sub NamespaceForAttributeName
-{
- my ($object, $interfaceName, $attributeName) = @_;
- return "SVGNames" if $interfaceName =~ /^SVG/ && !$svgAttributesInHTMLHash{$attributeName};
- return "HTMLNames";
-}
-
-# Identifies overloaded functions and for each function adds an array with
-# links to its respective overloads (including itself).
-sub LinkOverloadedFunctions
-{
- my ($object, $interface) = @_;
-
- my %nameToFunctionsMap = ();
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name};
- push(@{$nameToFunctionsMap{$name}}, $function);
- $function->{overloads} = $nameToFunctionsMap{$name};
- $function->{overloadIndex} = @{$nameToFunctionsMap{$name}};
- }
-}
-
-sub AttributeNameForGetterAndSetter
-{
- my ($generator, $attribute) = @_;
-
- my $attributeName = $attribute->signature->name;
- if ($attribute->signature->extendedAttributes->{"ImplementedAs"}) {
- $attributeName = $attribute->signature->extendedAttributes->{"ImplementedAs"};
- }
- my $attributeType = $attribute->signature->type;
-
- # Avoid clash with C++ keyword.
- $attributeName = "_operator" if $attributeName eq "operator";
-
- # SVGAElement defines a non-virtual "String& target() const" method which clashes with "virtual String target() const" in Element.
- # To solve this issue the SVGAElement method was renamed to "svgTarget", take care of that when calling this method.
- $attributeName = "svgTarget" if $attributeName eq "target" and $attributeType eq "SVGAnimatedString";
-
- # SVG animated types need to use a special attribute name.
- # The rest of the special casing for SVG animated types is handled in the language-specific code generators.
- $attributeName .= "Animated" if $generator->IsSVGAnimatedType($attributeType);
-
- return $attributeName;
-}
-
-sub ContentAttributeName
-{
- my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
-
- my $contentAttributeName = $attribute->signature->extendedAttributes->{"Reflect"};
- return undef if !$contentAttributeName;
-
- $contentAttributeName = lc $generator->AttributeNameForGetterAndSetter($attribute) if $contentAttributeName eq "VALUE_IS_MISSING";
-
- my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
-
- $implIncludes->{"${namespace}.h"} = 1;
- return "WebCore::${namespace}::${contentAttributeName}Attr";
-}
-
-sub CanUseFastAttribute
-{
- my ($generator, $attribute) = @_;
- my $attributeType = $attribute->signature->type;
- # HTMLNames::styleAttr cannot be used with fast{Get,Has}Attribute but we do not [Reflect] the
- # style attribute.
-
- return !$generator->IsSVGAnimatedType($attributeType);
-}
-
-sub GetterExpression
-{
- my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
-
- my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
-
- if (!$contentAttributeName) {
- return ($generator->WK_lcfirst($generator->AttributeNameForGetterAndSetter($attribute)));
- }
-
- my $functionName;
- if ($attribute->signature->extendedAttributes->{"URL"}) {
- $functionName = "getURLAttribute";
- } elsif ($attribute->signature->type eq "boolean") {
- my $namespace = $generator->NamespaceForAttributeName($interfaceName, $contentAttributeName);
- if ($generator->CanUseFastAttribute($attribute)) {
- $functionName = "fastHasAttribute";
- } else {
- $functionName = "hasAttribute";
- }
- } elsif ($attribute->signature->type eq "long") {
- $functionName = "getIntegralAttribute";
- } elsif ($attribute->signature->type eq "unsigned long") {
- $functionName = "getUnsignedIntegralAttribute";
- } else {
- if ($contentAttributeName eq "WebCore::HTMLNames::idAttr") {
- $functionName = "getIdAttribute";
- $contentAttributeName = "";
- } elsif ($contentAttributeName eq "WebCore::HTMLNames::nameAttr") {
- $functionName = "getNameAttribute";
- $contentAttributeName = "";
- } elsif ($generator->CanUseFastAttribute($attribute)) {
- $functionName = "fastGetAttribute";
- } else {
- $functionName = "getAttribute";
- }
- }
-
- return ($functionName, $contentAttributeName);
-}
-
-sub SetterExpression
-{
- my ($generator, $implIncludes, $interfaceName, $attribute) = @_;
-
- my $contentAttributeName = $generator->ContentAttributeName($implIncludes, $interfaceName, $attribute);
-
- if (!$contentAttributeName) {
- return ("set" . $generator->WK_ucfirst($generator->AttributeNameForGetterAndSetter($attribute)));
- }
-
- my $functionName;
- if ($attribute->signature->type eq "boolean") {
- $functionName = "setBooleanAttribute";
- } elsif ($attribute->signature->type eq "long") {
- $functionName = "setIntegralAttribute";
- } elsif ($attribute->signature->type eq "unsigned long") {
- $functionName = "setUnsignedIntegralAttribute";
- } else {
- $functionName = "setAttribute";
- }
-
- return ($functionName, $contentAttributeName);
-}
-
-sub GenerateConditionalString
-{
- my $generator = shift;
- my $node = shift;
-
- my $conditional = $node->extendedAttributes->{"Conditional"};
- if ($conditional) {
- return $generator->GenerateConditionalStringFromAttributeValue($conditional);
- } else {
- return "";
- }
-}
-
-sub GenerateConditionalStringFromAttributeValue
-{
- my $generator = shift;
- my $conditional = shift;
-
- my $operator = ($conditional =~ /&/ ? '&' : ($conditional =~ /\|/ ? '|' : ''));
- if ($operator) {
- # Avoid duplicated conditions.
- my %conditions;
- map { $conditions{$_} = 1 } split('\\' . $operator, $conditional);
- return "ENABLE(" . join(") $operator$operator ENABLE(", sort keys %conditions) . ")";
- } else {
- return "ENABLE(" . $conditional . ")";
- }
-}
-
-sub GenerateCompileTimeCheckForEnumsIfNeeded
-{
- my ($generator, $interface) = @_;
- my $interfaceName = $interface->name;
- my @checks = ();
- # If necessary, check that all constants are available as enums with the same value.
- if (!$interface->extendedAttributes->{"DoNotCheckConstants"} && @{$interface->constants}) {
- push(@checks, "\n");
- foreach my $constant (@{$interface->constants}) {
- my $reflect = $constant->extendedAttributes->{"Reflect"};
- my $name = $reflect ? $reflect : $constant->name;
- my $value = $constant->value;
- my $conditional = $constant->extendedAttributes->{"Conditional"};
-
- if ($conditional) {
- my $conditionalString = $generator->GenerateConditionalStringFromAttributeValue($conditional);
- push(@checks, "#if ${conditionalString}\n");
- }
-
- if ($constant->extendedAttributes->{"ImplementedBy"}) {
- push(@checks, "COMPILE_ASSERT($value == " . $constant->extendedAttributes->{"ImplementedBy"} . "::$name, ${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
- } else {
- push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name, ${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
- }
-
- if ($conditional) {
- push(@checks, "#endif\n");
- }
- }
- push(@checks, "\n");
- }
- return @checks;
-}
-
-sub ExtendedAttributeContains
-{
- my $object = shift;
- my $callWith = shift;
- return 0 unless $callWith;
- my $keyword = shift;
-
- my @callWithKeywords = split /\s*\|\s*/, $callWith;
- return grep { $_ eq $keyword } @callWithKeywords;
-}
-
-# FIXME: This is backwards. We currently name the interface and the IDL files with the implementation name. We
-# should use the real interface name in the IDL files and then use ImplementedAs to map this to the implementation name.
-sub GetVisibleInterfaceName
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->extendedAttributes->{"InterfaceName"};
- return $interfaceName ? $interfaceName : $interface->name;
-}
-
-sub IsSubType
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = shift;
- my $found = 0;
-
- return 1 if $interfaceName eq $interface->name;
- $object->ForAllParents($interface, sub {
- my $currentInterface = shift;
- if ($currentInterface->name eq $interfaceName) {
- $found = 1;
- }
- return "prune" if $found;
- }, 0, 1);
-
- return $found;
-}
-
-1;
diff --git a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm b/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm
deleted file mode 100644
index 64004d0..0000000
--- a/contrib/dom/scripts/CodeGeneratorArabicaJSC.pm
+++ /dev/null
@@ -1,1154 +0,0 @@
-# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
-# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
-# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
-# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
-# Copyright (C) 2006 Apple Computer, Inc.
-# Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
-# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
-# Copyright (C) Research In Motion Limited 2010. All rights reserved.
-# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-# Copyright (C) 2012 Ericsson AB. All rights reserved.
-# Copyright (C) 2013 Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this library; see the file COPYING.LIB. If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-
-package CodeGeneratorArabicaJSC;
-
-use strict;
-use Data::Dumper;
-use Carp qw/longmess cluck confess/;
-
-use constant FileNamePrefix => "JSC";
-
-my $codeGenerator;
-
-
-my @headerContent = ();
-my @implContentHeader = ();
-my @implContent = ();
-my @implContentDecls = ();
-my %implIncludes = ();
-my %headerIncludes = ();
-
-# Default .h template
-my $headerTemplate = << 'EOF';
-/**
- * @file
- * @author This file has been generated by generate-bindings.pl. DO NOT MODIFY!
- * @copyright Simplified BSD
- *
- * @cond
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the FreeBSD license as published by the FreeBSD
- * project.
- *
- * This program 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.
- *
- * You should have received a copy of the FreeBSD license along with this
- * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
- * @endcond
- */
-EOF
-
-# Default constructor
-sub new
-{
- my $object = shift;
- my $reference = { };
-
- $codeGenerator = shift;
-
- bless($reference, $object);
- return $reference;
-}
-
-sub GenerateInterface
-{
- my $object = shift;
- my $interface = shift;
-
- # Start actual generation
- if ($interface->extendedAttributes->{"Callback"}) {
- die();
- $object->GenerateCallbackHeader($interface);
- $object->GenerateCallbackImplementation($interface);
- } else {
- $object->GenerateHeader($interface);
- $object->GenerateImplementation($interface);
- }
-}
-
-sub AddToImplIncludes
-{
- my $header = shift;
- my $conditional = shift;
-
- if ($header eq "JSCbool.h") {
- confess();
- }
-
- if (not $conditional) {
- $implIncludes{$header} = 1;
- } elsif (not exists($implIncludes{$header})) {
- $implIncludes{$header} = $conditional;
- } else {
- my $oldValue = $implIncludes{$header};
- if ($oldValue ne 1) {
- my %newValue = ();
- $newValue{$conditional} = 1;
- foreach my $condition (split(/\|/, $oldValue)) {
- $newValue{$condition} = 1;
- }
- $implIncludes{$header} = join("|", sort keys %newValue);
- }
- }
-}
-
-sub GenerateHeader
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-# print Dumper($interface);
-
- # Copy contents of parent interfaces except the first parent.
- my @parents;
- $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents, 1);
- $codeGenerator->LinkOverloadedFunctions($interface);
-
- # - Add default header template
- push(@headerContent, GenerateHeaderContentHeader($interface));
-
- $headerIncludes{"uscxml/plugins/datamodel/ecmascript/JavaScriptCore/JSCDOM.h"} = 1;
- $headerIncludes{"DOM/Node.hpp"} = 1;
- $headerIncludes{"JavaScriptCore/JavaScriptCore.h"} = 1;
-
- if ($interfaceName =~ /.*Array$/ or $interfaceName =~ /^ArrayBuffer.*/) {
- $headerIncludes{"../../TypedArray.h"} = 1;
- }
-
- foreach (@{$interface->parents}) {
- my $parent = $_;
- $headerIncludes{"JSC${parent}.h"} = 1;
- }
-
- push(@headerContent, "#include \<string\>\n");
- foreach my $headerInclude (sort keys(%headerIncludes)) {
- if ($headerInclude =~ /wtf|JavaScriptCore\/JavaScriptCore\.h/) {
- push(@headerContent, "#include \<${headerInclude}\>\n");
- } else {
- push(@headerContent, "#include \"${headerInclude}\"\n");
- }
- }
-
- push(@headerContent, "");
- push(@headerContent, "\nnamespace Arabica {");
- push(@headerContent, "\nnamespace DOM {\n");
-
- push(@headerContent, "\nclass JSC${interfaceName} {");
- push(@headerContent, "\npublic:");
-
- my $wrapperType = IdlToWrapperType($interfaceName);
- push(@headerContent, <<END);
-
- struct JSC${interfaceName}Private {
- JSCDOM* dom;
- ${wrapperType}* nativeObj;
- };
-END
-
- if ($extensions->{'DontDestroyWrapped'}) {
- push(@headerContent, "\n JSC_DESTRUCTOR_KEEP_WRAPPED(JSC${interfaceName}Private);");
- } else {
- push(@headerContent, "\n JSC_DESTRUCTOR(JSC${interfaceName}Private);");
- }
- push(@headerContent, "\n");
-
-
- # callbacks for actual functions
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- next if (exists $generated{"${name}${custom}Callback"});
-
- push(@headerContent, "\n static JSValueRef ${name}${custom}Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception);");
- $generated{"${name}${custom}Callback"} = 1;
- }
- push(@headerContent, "\n");
-
- if ($extensions->{'Constructors'}) {
- push(@headerContent, "\n static JSObjectRef jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);");
- }
-
- # attribute getter and setters
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- push(@headerContent, "\n static JSValueRef ${name}${customGetter}AttrGetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);");
- if (!IsReadonly($attribute)) {
- push(@headerContent, "\n static bool ${name}${customSetter}AttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);");
- }
- }
-
- # const getters
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- my $value = $constant->value;
- my $getter = "${name}ConstGetter";
- push(@headerContent, "\n static JSValueRef ${getter}(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef* exception);");
- }
-
- if ($extensions->{'CustomIndexedGetter'}) {
- push(@headerContent, "\n static bool hasPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);");
- push(@headerContent, "\n static JSValueRef getPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);");
- }
- if ($extensions->{'CustomIndexedSetter'}) {
- push(@headerContent, "\n static bool setPropertyCustomCallback(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);");
- }
- push(@headerContent, "\n");
-
- push(@headerContent, <<END);
-
-
- static JSStaticValue staticValues[];
- static JSStaticFunction staticFunctions[];
-
- static JSClassRef Tmpl;
- static JSClassRef getTmpl() {
- if (Tmpl == NULL) {
- JSClassDefinition classDef = kJSClassDefinitionEmpty;
- classDef.staticValues = staticValues;
- classDef.staticFunctions = staticFunctions;
- classDef.finalize = jsDestructor;
-END
- push(@headerContent, " classDef.className = \"${interfaceName}\";\n");
- if ($extensions->{'CustomIndexedGetter'}) {
- push(@headerContent, " classDef.hasProperty = hasPropertyCustomCallback;\n");
- push(@headerContent, " classDef.getProperty = getPropertyCustomCallback;\n");
- }
- if ($extensions->{'CustomIndexedSetter'}) {
- push(@headerContent, " classDef.setProperty = setPropertyCustomCallback;\n");
- }
- if ($extensions->{'Constructors'}) {
- push(@headerContent, " classDef.callAsConstructor = jsConstructor;\n");
- }
- if (@{$interface->parents}) {
- my $parent = @{$interface->parents}[0];
- push(@headerContent, " classDef.parentClass = JSC${parent}::getTmpl();\n");
- }
-
- push(@headerContent, <<END);
-
- Tmpl = JSClassCreate(&classDef);
- JSClassRetain(Tmpl);
- }
- return Tmpl;
- }
-
-END
-
- push(@headerContent, "\n};\n\n}\n}\n\n");
- push(@headerContent, "#endif // JSC${interfaceName}" . "_h\n");
-
-}
-
-#
-# Write class template prototype constructor
-#
-sub GenerateClassDefStatics
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- push(@implContent, "\nJSStaticValue JSC${interfaceName}::staticValues[] = {");
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- my $getter = "${name}${customGetter}AttrGetter";
- my $setter = (IsReadonly($attribute) ? "0" : "${name}${customSetter}AttrSetter");
- my $flags = "kJSPropertyAttributeDontDelete";
- $flags .= " | kJSPropertyAttributeReadOnly" if (IsReadonly($attribute));
- push(@implContent, "\n { \"${name}\", ${getter}, ${setter}, ${flags} },");
-
- }
-
- push(@implContent, "\n");
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- my $value = $constant->value;
- my $getter = "${name}ConstGetter";
- my $flags = "kJSPropertyAttributeDontDelete | kJSPropertyAttributeReadOnly";
- push(@implContent, "\n { \"${name}\", ${getter}, 0, ${flags} },");
- }
-
- push(@implContent, "\n { 0, 0, 0, 0 }");
- push(@implContent, "\n};\n");
-
- push(@implContent, "\nJSStaticFunction JSC${interfaceName}::staticFunctions[] = {");
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- my $callback = ${name}.${custom}."Callback";
- my $flags = "kJSPropertyAttributeDontDelete";
- next if (exists $generated{"${name}"});
- $generated{"${name}"} = 1;
- push(@implContent, "\n { \"${name}\", ${callback}, ${flags} },");
-
- }
- push(@implContent, "\n { 0, 0, 0 }");
- push(@implContent, "\n};\n");
-
-}
-
-sub GenerateImplementationAttributes
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- # Generate property accessors for attributes.
- for (my $index = 0; $index < @{$interface->attributes}; $index++) {
- my $attribute = @{$interface->attributes}[$index];
- my $attrType = $attribute->signature->type;
- my $attrName = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
-
- my $wrapperRetType = IdlToWrapperType($attrType);
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $wrapperGetter;
-
- if ($attrExt->{'AttributeIsPublic'} || $extensions->{'AttributesArePublic'}) {
- $wrapperGetter = $attrName;
- } else {
- $wrapperGetter = IdlToWrapperAttrGetter($interface, $attribute)."()";
-
- }
-
- # getter
- if (!$attrExt->{'CustomGetter'}) {
- push(@implContent, <<END);
-
- JSValueRef JSC${interfaceName}::${attrName}AttrGetter(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef *exception) {
- struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(object);
-END
- if (IsWrapperType($attrType)) {
- AddToImplIncludes("JSC".$attrType.".h");
- push(@implContent, "\n ".GenerateConditionalUndefReturn($interface, $attribute, "privData->nativeObj->${wrapperGetter}"));
-
- push(@implContent, <<END);
-
- ${wrapperRetType}* arabicaRet = new ${wrapperRetType}(privData->nativeObj->${wrapperGetter});
-
- JSClassRef arbaicaRetClass = JSC${attrType}::getTmpl();
-
- struct JSC${attrType}::JSC${attrType}Private* retPrivData = new JSC${attrType}::JSC${attrType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = arabicaRet;
-
- JSObjectRef arbaicaRetObj = JSObjectMake(ctx, arbaicaRetClass, retPrivData);
- return arbaicaRetObj;
-END
- } else {
- my $JSCType = IdlToJSCType($attrType);
- if ($JSCType eq "String") {
- if ($attrExt->{'EmptyAsNull'}) {
- push(@implContent, "\n if (privData->nativeObj->${wrapperGetter}.length() == 0)");
- push(@implContent, "\n return JSValueMakeUndefined(ctx);");
- }
- push(@implContent, <<END);
-
- JSStringRef stringRef = JSStringCreateWithUTF8CString(privData->nativeObj->${wrapperGetter}.c_str());
- JSValueRef retVal = JSValueMakeString(ctx, stringRef);
- JSStringRelease(stringRef);
- return retVal;
-END
- } elsif($JSCType eq "Number") {
- push(@implContent, "\n return JSValueMakeNumber(ctx, privData->nativeObj->${wrapperGetter});\n");
- } elsif($JSCType eq "Boolean") {
- push(@implContent, "\n return JSValueMakeBoolean(ctx, privData->nativeObj->${wrapperGetter});\n");
- }
- }
- push(@implContent, " }\n\n");
- }
-
- if (!$attrExt->{'CustomSetter'}) {
- # setter
- if (!IsReadonly($attribute)) {
- push(@implContent, "\n bool JSC${interfaceName}::${attrName}AttrSetter(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef value, JSValueRef* exception) {");
- push(@implContent, "\n struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(thisObj);\n");
- my $wrapperSetter = IdlToWrapperAttrSetter($attrName);
-
- my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value");
-
- push(@implContent, "\n $handle");
- push(@implContent, "\n privData->nativeObj->${wrapperSetter}(${deref});");
- push(@implContent, "\n return true;");
- push(@implContent, "\n }\n");
-
- }
- }
- }
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- my $value = $constant->value;
- my $getter = "${name}ConstGetter";
- push(@implContent, " JSValueRef JSC${interfaceName}::${getter}(JSContextRef ctx, JSObjectRef thisObj, JSStringRef propertyName, JSValueRef *exception) {");
- my $JSCType = IdlToJSCType($constant->type);
- if ($JSCType eq "String") {
- push(@implContent,
- "\n JSStringRef jscString = JSStringCreateWithUTF8CString(" . $constant->value . ");".
- "\n JSValueRef retVal = JSValueMakeString(ctx, jscString);".
- "\n JSStringRelease(jscString);".
- "\n return retVal;\n");
- } elsif($JSCType eq "Number") {
- push(@implContent, "\n return JSValueMakeNumber(ctx, " . $constant->value . ");\n");
- } elsif($JSCType eq "Boolean") {
- push(@implContent, "\n return JSValueMakeBoolean(ctx, " . $constant->value . ");\n");
- }
- push(@implContent, <<END);
- }
-
-END
-
- }
-
-}
-
-sub GenerateConditionalUndefReturn
-{
- my $interface = shift;
- my $attribute = shift;
- my $getterExpression = shift;
-
- return "" if ($attribute->signature->type eq "NamedNodeMap");
- return "" if ($attribute->signature->type eq "NodeList");
- return "if (!$getterExpression) return JSValueMakeUndefined(ctx);";
-}
-
-sub GenerateConstructor
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
- my $wrapperType = IdlToWrapperType($interfaceName);
-
- if ($extensions->{'Constructors'}) {
- push(@implContent, <<END);
-
-JSObjectRef JSC${interfaceName}::jsConstructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
- ${wrapperType}* localInstance = NULL;
-END
-
-
- # dispatch the actual constructor
- push(@implContent, "\n if (false) {\n}");
- my @variants;
- foreach my $fullCons (@{$extensions->{'Constructors'}}) {
- push (@variants, $fullCons);
-
- for (my $i = @{$fullCons}; $i > 0; $i--) {
- my $variant = @{$fullCons}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$fullCons}[$j]);
- }
- push (@variants, $slice);
- }
- }
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
- }
- foreach my $constructor (@variants) {
- push(@implContent, " else if (argumentCount == " . @{$constructor});
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- AddToImplIncludes("JSC".$type.".h") if (IsWrapperType($type));
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "arguments[$i]"));
-
- }
-
- push(@implContent, ") {\n");
- my $constructorArgs;
- my $constructorSep = "";
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- my $name = $constructor->[$i]->{'domSignature::name'};
- my ($handle, $deref) = IdlToArgHandle($type, "local".ucfirst($name), "arguments[$i]", $interfaceName);
- $constructorArgs .= ${constructorSep}.${deref};
- $constructorSep = ", ";
- push(@implContent, "\n $handle");
-
- }
- push(@implContent, "\n localInstance = new ".IdlToWrapperType($interfaceName)."(${constructorArgs});");
- push(@implContent, "\n\n }");
-
- }
- push(@implContent, "\n");
-
- push(@implContent, <<END);
- if (!localInstance) {
- JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling constructor for ${interfaceName}");
- *exception = JSValueMakeString(ctx, exceptionString);
- JSStringRelease(exceptionString);
- return (JSObjectRef)JSValueMakeNull(ctx);
- }
-
- JSClassRef retClass = JSC${interfaceName}::getTmpl();
-
- struct JSC${interfaceName}::JSC${interfaceName}Private* retPrivData = new JSC${interfaceName}::JSC${interfaceName}Private();
- retPrivData->nativeObj = localInstance;
-
- JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
- return retObj;
- }
-END
- }
-}
-
-sub IdlToTypeChecker
-{
- my $idlType = shift;
- my $attr = shift;
-
- return "JSValueIsString(ctx, ${attr})" if ($idlType eq "DOMString");
- return "JSValueIsBoolean(ctx, ${attr})" if ($idlType eq "boolean");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "short");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "long");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "long[]");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "unsigned short");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "unsigned long");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "byte");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "octet");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "double");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "double[]");
- return "JSValueIsNumber(ctx, ${attr})" if ($idlType eq "float");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "float[]");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "short[]");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "unsigned short[]");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "unsigned long[]");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "byte[]");
- return "JSValueIsObject(ctx, ${attr})" if ($idlType eq "octet[]");
- return "true" if ($idlType eq "any");
-
- return "JSValueIsObject(ctx, ${attr}) && JSValueIsObjectOfClass(ctx, ${attr}, JSC${idlType}::getTmpl())" if (IsWrapperType($idlType));
-
- print $idlType."\n";
- die();
-
-}
-
-
-sub GenerateImplementationFunctionCallbacks
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $wrapperType = IdlToWrapperType($interfaceName);
-
- # Generate methods for functions.
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $retType = $function->signature->type;
- my $wrapperRetType = IdlToWrapperType($retType);
-
- next if ($attrExt->{'Custom'});
- next if (exists $generated{"${name}Callback"});
- $generated{"${name}Callback"} = 1;
-
- # get all functions with this name
- my @sameFunctions = grep($_->signature->name eq $name, @{$interface->functions});
-
- # signature
- push(@implContent, <<END);
-
- JSValueRef JSC${interfaceName}::${name}Callback(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObj, size_t argumentCount, const JSValueRef* arguments, JSValueRef* exception) {
-END
-
- # arguments count and type checking
- # push(@implContent, GenerateArgumentsCountCheck($function, $interface));
- # my $argCheckExpr = GenerateArgumentsTypeCheck($function, $interface);
-
- # get this
- push(@implContent, "\n struct JSC${interfaceName}Private* privData = (struct JSC${interfaceName}Private*)JSObjectGetPrivate(thisObj);\n");
-
- # establish all variants
- my @variants;
- foreach my $functionVar (@sameFunctions) {
- push (@variants, $functionVar->parameters);
-
- for (my $i = @{$functionVar->parameters}; $i > 0; $i--) {
- my $variant = @{$functionVar->parameters}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$functionVar->parameters}[$j]);
- }
- push (@variants, $slice);
- }
- }
- }
-
- # arguments to local handles
- push(@implContent, "\n if (false) {");
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
-
- foreach my $variant (@variants) {
- my $parameterIndex = 0;
- my @argList;
-
- push(@implContent, "\n } else if (argumentCount == " . @{$variant});
- for (my $i = 0; $i < @{$variant}; $i++) {
- my $type = $variant->[$i]->{'domSignature::type'};
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "arguments[$i]"));
- }
- push(@implContent, ")\n {");
- foreach my $parameter (@{$variant}) {
- my $type = $parameter->type;
- AddToImplIncludes("JSC".$type.".h") if (IsWrapperType($type));
-
- my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "arguments[${parameterIndex}]");
- push(@implContent, "\n ${handle}");
-# push(@implContent, "\n if (exception)\n return JSValueMakeUndefined(ctx);");
- push(@argList, $deref);
-
- $parameterIndex++;
- }
-
- # invoke native function with argument handles
- my $retNativeType = IdlToNativeType($retType);
- my $wrapperFunctionName = IdlToWrapperFunction($interface, $function);
- if (IsWrapperType($retType)) {
- push(@implContent, "\n\n ${retNativeType}* retVal = new $wrapperRetType(privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . "));\n");
- } elsif ($retNativeType eq "void") {
- push(@implContent, "\n\n privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- } else {
- push(@implContent, "\n\n ${retNativeType} retVal = privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- }
-
- # wrap return type if needed
- if (IsWrapperType($retType)) {
- AddToImplIncludes("JSC".$retType.".h");
-
- push(@implContent, <<END);
- JSClassRef retClass = JSC${retType}::getTmpl();
-
- struct JSC${retType}::JSC${retType}Private* retPrivData = new JSC${retType}::JSC${retType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
-
- JSObjectRef retObj = JSObjectMake(ctx, retClass, retPrivData);
-
- return retObj;
-END
- } else {
- my $toHandleString = NativeToHandle($retNativeType, "retVal", "jscRetVal");
- push(@implContent, "${toHandleString}\n return jscRetVal;");
- }
- }
- push(@implContent, <<END);
-
- }
-
- JSStringRef exceptionString = JSStringCreateWithUTF8CString("Parameter mismatch while calling ${name}");
- *exception = JSValueMakeString(ctx, exceptionString);
- JSStringRelease(exceptionString);
- return JSValueMakeUndefined(ctx);
- }
-END
- }
-
-}
-
-sub GenerateImplementation
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
- my $JSCInterfaceName = "JSC$interfaceName";
- my $wrapperType = IdlToWrapperType($interfaceName);
-
- AddToImplIncludes("JSC${interfaceName}.h");
-
- # Find the super descriptor.
- my $parentClass = "";
- my $parentClassTemplate = "";
- foreach (@{$interface->parents}) {
- my $parent = $_;
- AddToImplIncludes("JSC${parent}.h");
- $parentClass = "JSC" . $parent;
- last;
- }
-
- push(@implContent, "namespace Arabica {\n");
- push(@implContent, "namespace DOM {\n\n");
- push(@implContent, "JSClassRef JSC${interfaceName}::Tmpl;\n");
-
- GenerateClassDefStatics($interface);
- if ($interface->extendedAttributes->{'Constructors'}) {
- GenerateConstructor($interface);
- }
- GenerateImplementationAttributes($interface);
- GenerateImplementationFunctionCallbacks($interface);
-
- push(@implContent, <<END);
-
-}
-}
-END
-
- # We've already added the header for this file in implContentHeader, so remove
- # it from implIncludes to ensure we don't #include it twice.
-# delete $implIncludes{"${JSCInterfaceName}.h"};
-}
-
-sub WriteData
-{
- my $object = shift;
- my $interface = shift;
- my $outputDir = shift;
- my $outputHeadersDir = shift;
-
- my $name = $interface->name;
- my $prefix = FileNamePrefix;
- my $headerFileName = "$outputHeadersDir/$prefix$name.h";
- my $implFileName = "$outputDir/$prefix$name.cpp";
-
- # print "WriteData\n";
- # print Dumper($interface);
- # exit();
-
- # Update a .cpp file if the contents are changed.
- my $contents = $headerTemplate;
- $contents .= join "", @implContentHeader;
-
- my @includes = ();
- my %implIncludeConditions = ();
- foreach my $include (keys %implIncludes) {
- my $condition = $implIncludes{$include};
- my $checkType = $include;
- $checkType =~ s/\.h//;
- next if $codeGenerator->IsSVGAnimatedType($checkType);
-
- if ($include =~ /wtf/) {
- $include = "\<$include\>";
- } else {
- $include = "\"$include\"";
- }
-
- if ($condition eq 1) {
- push @includes, $include;
- } else {
- push @{$implIncludeConditions{$condition}}, $include;
- }
- }
- foreach my $include (sort @includes) {
- $contents .= "#include $include\n";
- }
- foreach my $condition (sort keys %implIncludeConditions) {
- $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n";
- foreach my $include (sort @{$implIncludeConditions{$condition}}) {
- $contents .= "#include $include\n";
- }
- $contents .= "#endif\n";
- }
-
- $contents .= "\n";
- $contents .= join "", @implContentDecls, @implContent;
- $codeGenerator->UpdateFile($implFileName, $contents);
-
- %implIncludes = ();
- @implContentHeader = ();
- @implContentDecls = ();
- @implContent = ();
-
- # Update a .h file if the contents are changed.
- $contents = join "", @headerContent;
- $codeGenerator->UpdateFile($headerFileName, $contents);
-
- @headerContent = ();
-}
-
-sub IdlToJSCType
-{
- my $idlType = shift;
- return "Number" if ($idlType eq "unsigned short");
- return "Number" if ($idlType eq "short");
- return "Number" if ($idlType eq "unsigned long");
- return "Number" if ($idlType eq "long");
- return "String" if ($idlType eq "DOMString");
- return "Boolean" if ($idlType eq "boolean");
- return "Number" if ($idlType eq "double");
- die($idlType);
-}
-
-sub IdlToNativeType
-{
- my $idlType = shift;
-
- return IdlToWrapperType($idlType) if (IsWrapperType($idlType));
-
- return "std::string" if ($idlType eq "DOMString");
- return "bool" if ($idlType eq "boolean");
- return "short" if ($idlType eq "short");
- return "long" if ($idlType eq "long");
- return "unsigned short" if ($idlType eq "unsigned short");
- return "unsigned long" if ($idlType eq "unsigned long");
- return "void" if ($idlType eq "void");
- return "char" if ($idlType eq "byte");
- return "unsigned char" if ($idlType eq "octet");
- return "double" if ($idlType eq "double");
- return "float" if ($idlType eq "float");
- die(${idlType});
-}
-
-sub NativeToHandle
-{
- my $nativeType = shift;
- my $nativeName = shift;
- my $paramName = shift;
-
- return ("\n JSValueRef ${paramName} = JSValueMakeBoolean(ctx, ${nativeName});") if ($nativeType eq "bool");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "double");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "float");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "short");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "char");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "unsigned char");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "unsigned short");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "unsigned long");
- return ("\n JSValueRef ${paramName} = JSValueMakeNumber(ctx, ${nativeName});") if ($nativeType eq "long");
- return ("\n JSValueRef ${paramName} = JSValueMakeUndefined(ctx);") if ($nativeType eq "void");
- return (
- "\n JSStringRef jscString = JSStringCreateWithUTF8CString(${nativeName}.c_str());".
- "\n JSValueRef ${paramName} = JSValueMakeString(ctx, jscString);".
- "\n JSStringRelease(jscString);"
- ) if ($nativeType eq "std::string");
-
- die($nativeType);
-}
-
-sub IdlToWrapperType
-{
- my $idlType = shift;
- return "Arabica::XPath::XPathValue<std::string>" if ($idlType eq "XPathResult");
- return "Arabica::XPath::NodeSet<std::string>" if ($idlType eq "NodeSet");
- return "Arabica::DOM::Node<std::string>" if ($idlType eq "Node");
- return "Arabica::DOM::Element<std::string>" if ($idlType eq "Element");
- return "uscxml::Event" if ($idlType eq "SCXMLEvent");
- return "uscxml::Storage" if ($idlType eq "Storage");
- return "uscxml::ArrayBuffer" if ($idlType eq "ArrayBuffer");
- return "uscxml::ArrayBufferView" if ($idlType eq "ArrayBufferView");
- return "uscxml::Int8Array" if ($idlType eq "Int8Array");
- return "uscxml::Uint8Array" if ($idlType eq "Uint8Array");
- return "uscxml::Uint8ClampedArray" if ($idlType eq "Uint8ClampedArray");
- return "uscxml::Int16Array" if ($idlType eq "Int16Array");
- return "uscxml::Uint16Array" if ($idlType eq "Uint16Array");
- return "uscxml::Int32Array" if ($idlType eq "Int32Array");
- return "uscxml::Uint32Array" if ($idlType eq "Uint32Array");
- return "uscxml::Float32Array" if ($idlType eq "Float32Array");
- return "uscxml::Float64Array" if ($idlType eq "Float64Array");
- return "uscxml::DataView" if ($idlType eq "DataView");
- return "Arabica::DOM::${idlType}<std::string>";
-}
-
-sub IdlToArgHandle
-{
- my $type = shift;
- my $localName = shift;
- my $paramName = shift;
- if ($type eq "DOMString") {
- return (
- "JSStringRef stringRef${localName} = JSValueToStringCopy(ctx, ${paramName}, exception);\n" .
- "\t\tsize_t ${localName}MaxSize = JSStringGetMaximumUTF8CStringSize(stringRef${localName});\n" .
- "\t\tchar* ${localName}Buffer = new char[${localName}MaxSize];\n" .
- "\t\tJSStringGetUTF8CString(stringRef${localName}, ${localName}Buffer, ${localName}MaxSize);\n" .
- "\t\tstd::string ${localName}(${localName}Buffer);\n" .
- "\t\tJSStringRelease(stringRef${localName});\n" .
- "\t\tfree(${localName}Buffer);\n",
- "${localName}") ;
- }
- return ("unsigned long ${localName} = (unsigned long)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned long");
- return ("long ${localName} = (long)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "long");
- return ("unsigned short ${localName} = (unsigned short)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "unsigned short");
- return ("float ${localName} = (float)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "float");
- return ("double ${localName} = (double)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "double");
- return ("short ${localName} = (short)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "short");
- return ("char ${localName} = (char)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "byte");
- return ("unsigned char ${localName} = (unsigned char)JSValueToNumber(ctx, ${paramName}, exception);", ${localName}) if ($type eq "octet");
- return ("bool ${localName} = JSValueToBoolean(ctx, ${paramName});", ${localName}) if ($type eq "boolean");
- return ("void* ${localName} = JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception));", ${localName}) if ($type eq "any");
-
- if ($type =~ /(.*)\[\]$/) {
- my $nativeType = $1;
- $nativeType = "char" if ($nativeType =~ /^byte$/);
- $nativeType = "unsigned char" if ($nativeType =~ /^octet$/);
- return ("\
- std::vector<${nativeType}> ${localName};\n\
- JSValueRef ${localName}Item;
- unsigned int ${localName}Index = 0;
- while((${localName}Item = JSObjectGetPropertyAtIndex(ctx, JSValueToObject(ctx, ${paramName}, exception), ${localName}Index, exception))) {\
- if (JSValueIsUndefined(ctx, ${localName}Item))\
- break;\
- if (JSValueIsNumber(ctx,${localName}Item))\
- ${localName}.push_back(JSValueToNumber(ctx, ${localName}Item, exception));\
- ${localName}Index++;\
- }", "${localName}");
- }
- # return ("std::vector<float> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "float[]");
- # return ("std::vector<double> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "double[]");
- # return ("std::vector<char> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "byte[]");
- # return ("std::vector<short> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "short[]");
- # return ("std::vector<unsigned short> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned short[]");
- # return ("std::vector<unsigned long> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned long[]");
- # return ("std::vector<unsigned char> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "octet[]");
-
- if (IsWrapperType($type)) {
- my $wrapperType = IdlToWrapperType($type);
- if ($wrapperType =~ /^Arabica.*/) {
- return ("${wrapperType}* ${localName} = ((struct JSC${type}::JSC${type}Private*)JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception)))->nativeObj;", "*${localName}");
- } else {
- return ("${wrapperType}* ${localName} = ((struct JSC${type}::JSC${type}Private*)JSObjectGetPrivate(JSValueToObject(ctx, ${paramName}, exception)))->nativeObj;", "${localName}");
- }
- }
-
- print $type."\n";
- die();
-}
-
-sub IdlToWrapperAttrGetter
-{
- my $interface = shift;
- my $attribute = shift;
-
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "size");
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "empty");
- return "asString" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "stringValue");
- return "asBool" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "booleanValue");
- return "asNumber" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "numberValue");
-
- return "get" . ucfirst($attribute->signature->name);
-}
-
-sub IdlToWrapperFunction
-{
- my $interface = shift;
- my $function = shift;
-
- # if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder") {
- # print Dumper($interface);
- # print Dumper($function);
- # }
-
- return "to_document_order" if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder");
-
- return $function->signature->name;
-
-}
-
-sub IdlToWrapperAttrSetter
-{
- my $idlAttr = shift;
- return "set" . ucfirst($idlAttr);
-}
-
-
-sub IsReadonly
-{
- my $attribute = shift;
- my $attrExt = $attribute->signature->extendedAttributes;
- return ($attribute->type =~ /readonly/ || $attrExt->{"JSCReadOnly"}) && !$attrExt->{"Replaceable"};
-}
-
-
-sub GenerateArgumentsCountCheck
-{
- my $function = shift;
- my $interface = shift;
-
- my $numMandatoryParams = 0;
- my $allowNonOptional = 1;
- foreach my $param (@{$function->parameters}) {
- if ($param->extendedAttributes->{"Optional"} or $param->isVariadic) {
- $allowNonOptional = 0;
- } else {
- die "An argument must not be declared to be optional unless all subsequent arguments to the operation are also optional." if !$allowNonOptional;
- $numMandatoryParams++;
- }
- }
-
- my $argumentsCountCheckString = "";
- if ($numMandatoryParams >= 1) {
- $argumentsCountCheckString .=
-" if (argumentCount < $numMandatoryParams) {\n".
-" std::string errorMsg = \"Wrong number of arguments in " . $function->signature->name . "\";\n" .
-" JSStringRef string = JSStringCreateWithUTF8CString(errorMsg.c_str());\n".
-" JSValueRef exceptionString =JSValueMakeString(ctx, string);\n".
-" JSStringRelease(string);\n".
-" *exception = JSValueToObject(ctx, exceptionString, NULL);\n".
-" return NULL;\n".
-" }\n";
- }
- return $argumentsCountCheckString;
-}
-
-sub GenerateArgumentsTypeCheck
-{
- my $function = shift;
- my $interface = shift;
-
- my @andExpression = ();
-
- my $parameterIndex = 0;
- foreach my $parameter (@{$function->parameters}) {
- my $value = "arguments[$parameterIndex]";
- my $type = $parameter->type;
-
- # Only DOMString or wrapper types are checked.
- # For DOMString with StrictTypeChecking only Null, Undefined and Object
- # are accepted for compatibility. Otherwise, no restrictions are made to
- # match the non-overloaded behavior.
- # FIXME: Implement WebIDL overload resolution algorithm.
- if ($codeGenerator->IsStringType($type)) {
- if ($parameter->extendedAttributes->{"StrictTypeChecking"}) {
- push(@andExpression, "(${value}->IsNull() || ${value}->IsUndefined() || ${value}->IsString() || ${value}->IsObject())");
- }
- } elsif ($parameter->extendedAttributes->{"Callback"}) {
- # For Callbacks only checks if the value is null or object.
- push(@andExpression, "(${value}->IsNull() || ${value}->IsFunction())");
- } elsif ($codeGenerator->IsArrayType($type) || $codeGenerator->GetSequenceType($type)) {
- if ($parameter->isNullable) {
- push(@andExpression, "(${value}->IsNull() || ${value}->IsArray())");
- } else {
- push(@andExpression, "(${value}->IsArray())");
- }
- } elsif (IsWrapperType($type)) {
- if ($parameter->isNullable) {
- push(@andExpression, "(${value}->IsNull() || JSC${type}::hasInstance($value))");
- } else {
- push(@andExpression, "(JSC${type}::hasInstance($value))");
- }
- }
-
- $parameterIndex++;
- }
- my $res = join(" && ", @andExpression);
- $res = "($res)" if @andExpression > 1;
- return $res;
-}
-
-
-my %non_wrapper_types = (
- 'CompareHow' => 1,
- 'DOMObject' => 1,
- 'DOMString' => 1,
- 'DOMString[]' => 1,
- 'DOMTimeStamp' => 1,
- 'Date' => 1,
- 'Dictionary' => 1,
- 'EventListener' => 1,
- # FIXME: When EventTarget is an interface and not a mixin, fix this so that
- # EventTarget is treated as a wrapper type.
- 'EventTarget' => 1,
- 'IDBKey' => 1,
- 'JSObject' => 1,
- 'MediaQueryListListener' => 1,
- 'NodeFilter' => 1,
- 'SerializedScriptValue' => 1,
- 'any' => 1,
- 'boolean' => 1,
- 'double' => 1,
- 'float' => 1,
- 'int' => 1,
- 'long long' => 1,
- 'long' => 1,
- 'long[]' => 1,
- 'short' => 1,
- 'short[]' => 1,
- 'void' => 1,
- 'byte' => 1,
- 'octet' => 1,
- 'char' => 1,
- 'float[]' => 1,
- 'byte[]' => 1,
- 'float' => 1,
- 'double[]' => 1,
- 'double' => 1,
- 'unsigned int' => 1,
- 'unsigned long long' => 1,
- 'unsigned long' => 1,
- 'unsigned long[]' => 1,
- 'unsigned short' => 1,
- 'unsigned short[]' => 1,
- 'octet[]' => 1
-);
-
-sub IsWrapperType
-{
- my $type = shift;
- return !($non_wrapper_types{$type});
-}
-
-sub GenerateHeaderContentHeader
-{
- my $interface = shift;
- my $JSCInterfaceName = "JSC" . $interface->name;
- my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
-
- my @headerContentHeader = split("\r", $headerTemplate);
-
- push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString;
- push(@headerContentHeader, "\n#ifndef ${JSCInterfaceName}" . "_h");
- push(@headerContentHeader, "\n#define ${JSCInterfaceName}" . "_h\n\n");
- return @headerContentHeader;
-}
-
-1;
diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.pm
deleted file mode 100644
index 0095f6b..0000000
--- a/contrib/dom/scripts/CodeGeneratorArabicaV8.pm
+++ /dev/null
@@ -1,1023 +0,0 @@
-# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
-# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
-# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
-# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
-# Copyright (C) 2006 Apple Computer, Inc.
-# Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
-# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
-# Copyright (C) Research In Motion Limited 2010. All rights reserved.
-# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-# Copyright (C) 2012 Ericsson AB. All rights reserved.
-# Copyright (C) 2013 Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this library; see the file COPYING.LIB. If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-
-package CodeGeneratorArabicaV8;
-
-use strict;
-use Data::Dumper;
-use Carp qw/longmess cluck confess/;
-
-use constant FileNamePrefix => "V8";
-
-my $codeGenerator;
-
-
-my @headerContent = ();
-my @implContentHeader = ();
-my @implContent = ();
-my @implContentDecls = ();
-my %implIncludes = ();
-my %headerIncludes = ();
-
-# Default .h template
-my $headerTemplate = << 'EOF';
-/**
- * @file
- * @author This file has been generated by generate-bindings.pl. DO NOT MODIFY!
- * @copyright Simplified BSD
- *
- * @cond
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the FreeBSD license as published by the FreeBSD
- * project.
- *
- * This program 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.
- *
- * You should have received a copy of the FreeBSD license along with this
- * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
- * @endcond
- */
-
-EOF
-
-# Default constructor
-sub new
-{
- my $object = shift;
- my $reference = { };
-
- $codeGenerator = shift;
-
- bless($reference, $object);
- return $reference;
-}
-
-sub GenerateInterface
-{
- my $object = shift;
- my $interface = shift;
-
-# print Dumper($interface);
-
- # Start actual generation
- if ($interface->extendedAttributes->{"Callback"}) {
- die();
- $object->GenerateCallbackHeader($interface);
- $object->GenerateCallbackImplementation($interface);
- } else {
- $object->GenerateHeader($interface);
- $object->GenerateImplementation($interface);
- }
-}
-
-sub AddToImplIncludes
-{
- my $header = shift;
- my $conditional = shift;
-
- if ($header eq "V8bool.h") {
- confess();
- }
-
- if (not $conditional) {
- $implIncludes{$header} = 1;
- } elsif (not exists($implIncludes{$header})) {
- $implIncludes{$header} = $conditional;
- } else {
- my $oldValue = $implIncludes{$header};
- if ($oldValue ne 1) {
- my %newValue = ();
- $newValue{$conditional} = 1;
- foreach my $condition (split(/\|/, $oldValue)) {
- $newValue{$condition} = 1;
- }
- $implIncludes{$header} = join("|", sort keys %newValue);
- }
- }
-}
-
-sub GenerateHeader
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-# print Dumper($extensions);
-
- # Copy contents of parent interfaces except the first parent.
- my @parents;
- $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents, 1);
- $codeGenerator->LinkOverloadedFunctions($interface);
-
- # - Add default header template
- push(@headerContent, GenerateHeaderContentHeader($interface));
-
- $headerIncludes{"string"} = 1;
- $headerIncludes{"uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"} = 1;
- $headerIncludes{"DOM/Node.hpp"} = 1;
- $headerIncludes{"v8.h"} = 1;
-
- if ($interfaceName =~ /.*Array$/ or $interfaceName =~ /^ArrayBuffer.*/) {
- $headerIncludes{"../../TypedArray.h"} = 1;
- }
-
- foreach (@{$interface->parents}) {
- my $parent = $_;
- $headerIncludes{"V8${parent}.h"} = 1;
- }
-
- push(@headerContent, "#include \<string\>\n");
- foreach my $headerInclude (sort keys(%headerIncludes)) {
- if ($headerInclude =~ /wtf|v8\.h/) {
- push(@headerContent, "#include \<${headerInclude}\>\n");
- } else {
- push(@headerContent, "#include \"${headerInclude}\"\n");
- }
- }
-
- push(@headerContent, "");
- push(@headerContent, "\nnamespace Arabica {");
- push(@headerContent, "\nnamespace DOM {\n");
-
- push(@headerContent, "\nclass V8${interfaceName} {");
- push(@headerContent, "\npublic:");
-
- my $wrapperType = IdlToWrapperType($interfaceName);
- push(@headerContent, <<END);
-
- struct V8${interfaceName}Private {
- V8DOM* dom;
- ${wrapperType}* nativeObj;
- };
-END
-
- if ($extensions->{'DontDestroyWrapped'}) {
- push(@headerContent, "\n V8_DESTRUCTOR_KEEP_WRAPPED(V8${interfaceName}Private);");
- } else {
- push(@headerContent, "\n V8_DESTRUCTOR(V8${interfaceName}Private);");
- }
- push(@headerContent, "\n static bool hasInstance(v8::Handle<v8::Value>);");
- push(@headerContent, "\n");
-
- # callbacks for actual functions
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- next if (exists $generated{"${name}${custom}Callback"});
- push(@headerContent, "\n static v8::Handle<v8::Value> ${name}${custom}Callback(const v8::Arguments&);");
- $generated{"${name}${custom}Callback"} = 1;
- }
- push(@headerContent, "\n");
-
- # attribute getter and setters
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- push(@headerContent, "\n static v8::Handle<v8::Value> ${name}${customGetter}AttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info);");
- if (!IsReadonly($attribute)) {
- push(@headerContent, "\n static void ${name}${customSetter}AttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info);");
- }
- }
-
- if ($extensions->{'CustomIndexedGetter'}) {
- push(@headerContent, "\n static v8::Handle<v8::Value> indexedPropertyCustomGetter(uint32_t, const v8::AccessorInfo&);");
- }
- if ($extensions->{'CustomIndexedSetter'}) {
- push(@headerContent, "\n static v8::Handle<v8::Value> indexedPropertyCustomSetter(uint32_t, v8::Local<v8::Value>, const v8::AccessorInfo&);");
- }
- push(@headerContent, "\n");
-
- GenerateClassPrototypeHeader($interface);
-
- push(@headerContent, "\n};\n\n}\n}\n\n");
- push(@headerContent, "#endif // V8${interfaceName}" . "_h\n");
-
-}
-
-#
-# Write class template prototype constructor
-#
-sub GenerateClassPrototypeHeader
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- if ($extensions->{'Constructors'}) {
-
- push(@headerContent, "\n");
- push(@headerContent, " static v8::Handle<v8::Value> constructor(const v8::Arguments&);\n");
- push(@headerContent, " static v8::Persistent<v8::FunctionTemplate> Constr;\n");
- push(@headerContent, <<END);
- static v8::Handle<v8::FunctionTemplate> getConstructor() {
- if (Constr.IsEmpty()) {
- v8::Handle<v8::FunctionTemplate> constr = v8::FunctionTemplate::New(constructor);
- Constr = v8::Persistent<v8::FunctionTemplate>::New(constr);
- }
- return Constr;
- }
-END
- }
-
- push(@headerContent, "\n static v8::Persistent<v8::FunctionTemplate> Tmpl;\n");
- push(@headerContent, <<END);
- static v8::Handle<v8::FunctionTemplate> getTmpl() {
- if (Tmpl.IsEmpty()) {
- v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
- tmpl->SetClassName(v8::String::New("${interfaceName}"));
- tmpl->ReadOnlyPrototype();
-
- v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
- v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
- (void)prototype; // surpress unused warnings
-
- instance->SetInternalFieldCount(1);
-END
-
- push(@headerContent, "\n");
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- my $getter = "V8${interfaceName}::${name}${customGetter}AttrGetter";
- my $setter = (IsReadonly($attribute) ? "0" : "V8${interfaceName}::${name}${customSetter}AttrSetter");
- push(@headerContent, <<END);
- instance->SetAccessor(v8::String::NewSymbol("${name}"), ${getter}, ${setter},
- v8::External::New(0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None));
-END
- }
-
- if ($extensions->{'CustomIndexedGetter'} || $extensions->{'CustomIndexedSetter'}) {
- my $indexedGetter = ($extensions->{'CustomIndexedGetter'} ? "V8${interfaceName}::indexedPropertyCustomGetter" : 0);
- my $indexedSetter = ($extensions->{'CustomIndexedSetter'} ? "V8${interfaceName}::indexedPropertyCustomSetter" : 0);
- push(@headerContent, "\n instance->SetIndexedPropertyHandler(${indexedGetter}, ${indexedSetter});");
- }
-
- push(@headerContent, "\n");
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- next if (exists $generated{"${name}"});
- $generated{"${name}"} = 1;
- push(@headerContent, <<END);
- prototype->Set(v8::String::NewSymbol("${name}"),
- v8::FunctionTemplate::New(V8${interfaceName}::${name}${custom}Callback, v8::Undefined()), static_cast<v8::PropertyAttribute>(v8::DontDelete));
-END
- }
-
- push(@headerContent, "\n");
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- my $value = $constant->value;
- my $type = IdlToV8Type($constant->type);
- push(@headerContent, <<END);
- tmpl->Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
- prototype->Set(v8::String::NewSymbol("${name}"), ${type}::New(${value}), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
-END
- }
-
- push(@headerContent, "\n");
- if (@{$interface->parents}) {
- my $parent = @{$interface->parents}[0];
- push(@headerContent, " tmpl->Inherit(V8${parent}::getTmpl());\n");
- }
- push(@headerContent, <<END);
- Tmpl = v8::Persistent<v8::FunctionTemplate>::New(tmpl);
- }
- return Tmpl;
- }
-
-END
-
-}
-
-sub GenerateImplementationAttributes
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- # Generate property accessors for attributes.
- for (my $index = 0; $index < @{$interface->attributes}; $index++) {
- my $attribute = @{$interface->attributes}[$index];
- my $attrType = $attribute->signature->type;
- my $attrName = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
-
- my $wrapperRetType = IdlToWrapperType($attrType);
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $wrapperGetter;
-
- if ($attrExt->{'AttributeIsPublic'} || $extensions->{'AttributesArePublic'}) {
- $wrapperGetter = $attrName;
- } else {
- $wrapperGetter = IdlToWrapperAttrGetter($interface, $attribute)."()";
-
- }
-
- # getter
- if (!$attrExt->{'CustomGetter'}) {
- push(@implContent, <<END);
-
- v8::Handle<v8::Value> V8${interfaceName}::${attrName}AttrGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
- v8::Local<v8::Object> self = info.Holder();
- struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));
-END
- if (IsWrapperType($attrType)) {
- AddToImplIncludes("V8".$attrType.".h");
- push(@implContent, "\n ".GenerateConditionalUndefReturn($interface, $attribute, "privData->nativeObj->${wrapperGetter}"));
-
- push(@implContent, <<END);
-
- ${wrapperRetType}* arbaicaRet = new ${wrapperRetType}(privData->nativeObj->${wrapperGetter});
-
- v8::Handle<v8::Function> arbaicaRetCtor = V8${attrType}::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj = v8::Persistent<v8::Object>::New(arbaicaRetCtor->NewInstance());
-
- struct V8${attrType}::V8${attrType}Private* retPrivData = new V8${attrType}::V8${attrType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = arbaicaRet;
-
- arbaicaRetObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.MakeWeak(0, V8${attrType}::jsDestructor);
- return arbaicaRetObj;
-END
- } else {
- my $v8Type = IdlToV8Type($attrType);
- if ($attrType eq "DOMString") {
- if ($attrExt->{'EmptyAsNull'}) {
- push(@implContent, "\n if (privData->nativeObj->${wrapperGetter}.length() == 0)");
- push(@implContent, "\n return v8::Undefined();");
- }
- push(@implContent, "\n return ${v8Type}::New(privData->nativeObj->${wrapperGetter}.c_str());");
- } else {
- push(@implContent, "\n return ${v8Type}::New(privData->nativeObj->${wrapperGetter});");
- }
- }
- push(@implContent, "\n }\n");
- }
-
- if (!$attrExt->{'CustomSetter'}) {
- # setter
- if (!IsReadonly($attribute)) {
- my $wrapperSetter = IdlToWrapperAttrSetter($attrName);
- push(@implContent, "\n void V8${interfaceName}::${attrName}AttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {");
- push(@implContent, "\n v8::Local<v8::Object> self = info.Holder();");
- push(@implContent, "\n struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));");
-
- my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value", $interfaceName);
-
- push(@implContent, "\n $handle");
- push(@implContent, "\n privData->nativeObj->${wrapperSetter}(${deref});");
- push(@implContent, "\n }\n");
-
- }
- }
- }
-}
-
-sub GenerateConditionalUndefReturn
-{
- my $interface = shift;
- my $attribute = shift;
- my $getterExpression = shift;
-
- return "" if ($attribute->signature->type eq "NamedNodeMap");
- return "" if ($attribute->signature->type eq "NodeList");
- return "if (!$getterExpression) return v8::Undefined();";
-}
-
-sub GenerateConstructor
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
- if ($extensions->{'Constructors'}) {
-
- push(@implContent, "\n v8::Handle<v8::Value> V8${interfaceName}::constructor(const v8::Arguments& args) {");
- push(@implContent, <<END);
-
- if (!args.IsConstructCall())
- return v8::ThrowException(v8::String::New("Cannot call constructor as function"));
-END
-
- push(@implContent, "\n ".IdlToWrapperType($interfaceName)."* localInstance = NULL;");
- # dispatch the actual constructor
- push(@implContent, "\n if (false) {\n}");
- my @variants;
- foreach my $fullCons (@{$extensions->{'Constructors'}}) {
- push (@variants, $fullCons);
-
- for (my $i = @{$fullCons}; $i > 0; $i--) {
- my $variant = @{$fullCons}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$fullCons}[$j]);
- }
- push (@variants, $slice);
- }
- }
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
- }
- foreach my $constructor (@variants) {
- push(@implContent, " else if (args.Length() == " . @{$constructor});
-
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- AddToImplIncludes("V8".$type.".h") if (IsWrapperType($type));
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "args[$i]"));
-
- }
- push(@implContent, ") {\n");
- my $constructorArgs;
- my $constructorSep = "";
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- my $name = $constructor->[$i]->{'domSignature::name'};
- my ($handle, $deref) = IdlToArgHandle($type, "local".ucfirst($name), "args[$i]", $interfaceName);
- $constructorArgs .= ${constructorSep}.${deref};
- $constructorSep = ", ";
- push(@implContent, "\n $handle");
-
- }
- push(@implContent, "\n localInstance = new ".IdlToWrapperType($interfaceName)."(${constructorArgs});");
- push(@implContent, "\n\n }");
- }
- push(@implContent, "\n");
-
- push(@implContent, <<END);
- if (!localInstance) {
- throw V8Exception("Parameter mismatch while calling constructor for ${interfaceName}");
- return v8::Undefined();
- }
-
- v8::Handle<v8::Function> retCtor = V8${interfaceName}::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
-
- struct V8${interfaceName}::V8${interfaceName}Private* retPrivData = new V8${interfaceName}::V8${interfaceName}Private();
- retPrivData->nativeObj = localInstance;
-
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
-
- retObj.MakeWeak(0, V8${interfaceName}::jsDestructor);
- return retObj;
- }
-END
- }
-
-}
-
-sub GenerateImplementationFunctionCallbacks
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
-
- # Generate methods for functions.
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $retType = $function->signature->type;
- my $wrapperRetType = IdlToWrapperType($retType);
-
- next if ($attrExt->{'Custom'});
- next if (exists $generated{"${name}Callback"});
- $generated{"${name}Callback"} = 1;
-
- # get all functions with this name
- my @sameFunctions = grep($_->signature->name eq $name, @{$interface->functions});
-
- # signature
- push(@implContent, <<END);
-
- v8::Handle<v8::Value> V8${interfaceName}::${name}Callback(const v8::Arguments& args) {
-END
-
- # get this
- push(@implContent, "\n v8::Local<v8::Object> self = args.Holder();");
- push(@implContent, "\n struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));");
-
- # establish all variants
- my @variants;
- foreach my $functionVar (@sameFunctions) {
- push (@variants, $functionVar->parameters);
-
- for (my $i = @{$functionVar->parameters}; $i > 0; $i--) {
- my $variant = @{$functionVar->parameters}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$functionVar->parameters}[$j]);
- }
- push (@variants, $slice);
- }
- }
- }
-
- # arguments to local handles
- push(@implContent, "\n if (false) {");
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
-
- foreach my $variant (@variants) {
- my $parameterIndex = 0;
- my @argList;
-
- push(@implContent, "\n } else if (args.Length() == " . @{$variant});
- for (my $i = 0; $i < @{$variant}; $i++) {
- my $type = $variant->[$i]->{'domSignature::type'};
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "args[$i]"));
- }
- push(@implContent, ")\n {");
- foreach my $parameter (@{$variant}) {
- my $value = "args[$parameterIndex]";
- my $type = $parameter->type;
- AddToImplIncludes("V8".$type.".h") if (IsWrapperType($type));
-
- my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "args[${parameterIndex}]", $interfaceName);
- push(@implContent, "\n ${handle}");
- push(@argList, $deref);
- $parameterIndex++;
- }
-
- # invoke native function with argument handles
- my $retNativeType = IdlToNativeType($retType);
- my $wrapperFunctionName = IdlToWrapperFunction($interface, $function);
- if (IsWrapperType($retType)) {
- push(@implContent, "\n\n ${retNativeType}* retVal = new $wrapperRetType(privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . "));\n");
- } elsif ($retNativeType eq "void") {
- push(@implContent, "\n\n privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- } else {
- push(@implContent, "\n\n ${retNativeType} retVal = privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- }
-
- # wrap return type if needed
- if (IsWrapperType($retType)) {
- AddToImplIncludes("V8".$retType.".h");
-
- push(@implContent, <<END);
- v8::Handle<v8::Function> retCtor = V8${retType}::getTmpl()->GetFunction();
- v8::Persistent<v8::Object> retObj = v8::Persistent<v8::Object>::New(retCtor->NewInstance());
-
- struct V8${retType}::V8${retType}Private* retPrivData = new V8${retType}::V8${retType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
-
- retObj->SetInternalField(0, V8DOM::toExternal(retPrivData));
-
- retObj.MakeWeak(0, V8${retType}::jsDestructor);
- return retObj;
-END
- } else {
- my $toHandleString = NativeToHandle($retNativeType, "retVal");
- push(@implContent, "\n return ${toHandleString};");
- }
- }
- push(@implContent, <<END);
-
- }
- throw V8Exception("Parameter mismatch while calling ${name}");
- return v8::Undefined();
- }
-END
- }
-
-}
-
-sub GenerateImplementation
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
- my $v8InterfaceName = "V8$interfaceName";
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
- AddToImplIncludes("V8${interfaceName}.h");
-
- # Find the super descriptor.
- my $parentClass = "";
- my $parentClassTemplate = "";
- foreach (@{$interface->parents}) {
- my $parent = $_;
- AddToImplIncludes("V8${parent}.h");
- $parentClass = "V8" . $parent;
- last;
- }
-
- push(@implContent, "namespace Arabica {\n");
- push(@implContent, "namespace DOM {\n\n");
- push(@implContent, " v8::Persistent<v8::FunctionTemplate> V8${interfaceName}::Tmpl;\n");
-
- if ($extensions->{'Constructors'}) {
- push(@implContent, " v8::Persistent<v8::FunctionTemplate> V8${interfaceName}::Constr;\n");
- GenerateConstructor($interface);
- }
-
- GenerateImplementationAttributes($interface);
- GenerateImplementationFunctionCallbacks($interface);
-
-
- push(@implContent, <<END);
- bool V8${interfaceName}::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl()->HasInstance(value);
- }
-
-}
-}
-END
-
- # We've already added the header for this file in implContentHeader, so remove
- # it from implIncludes to ensure we don't #include it twice.
-# delete $implIncludes{"${v8InterfaceName}.h"};
-}
-
-sub WriteData
-{
- my $object = shift;
- my $interface = shift;
- my $outputDir = shift;
- my $outputHeadersDir = shift;
-
- my $name = $interface->name;
- my $prefix = FileNamePrefix;
- my $headerFileName = "$outputHeadersDir/$prefix$name.h";
- my $implFileName = "$outputDir/$prefix$name.cpp";
-
- # print "WriteData\n";
- # print Dumper($interface);
- # exit();
-
- # Update a .cpp file if the contents are changed.
- my $contents = $headerTemplate;
- $contents .= join "", @implContentHeader;
-
- my @includes = ();
- my %implIncludeConditions = ();
- foreach my $include (keys %implIncludes) {
- my $condition = $implIncludes{$include};
- my $checkType = $include;
- $checkType =~ s/\.h//;
- next if $codeGenerator->IsSVGAnimatedType($checkType);
-
- if ($include =~ /wtf/) {
- $include = "\<$include\>";
- } else {
- $include = "\"$include\"";
- }
-
- if ($condition eq 1) {
- push @includes, $include;
- } else {
- push @{$implIncludeConditions{$condition}}, $include;
- }
- }
- foreach my $include (sort @includes) {
- $contents .= "#include $include\n";
- }
- foreach my $condition (sort keys %implIncludeConditions) {
- $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n";
- foreach my $include (sort @{$implIncludeConditions{$condition}}) {
- $contents .= "#include $include\n";
- }
- $contents .= "#endif\n";
- }
-
- $contents .= "\n";
- $contents .= join "", @implContentDecls, @implContent;
- $codeGenerator->UpdateFile($implFileName, $contents);
-
- %implIncludes = ();
- @implContentHeader = ();
- @implContentDecls = ();
- @implContent = ();
-
- # Update a .h file if the contents are changed.
- $contents = join "", @headerContent;
- $codeGenerator->UpdateFile($headerFileName, $contents);
-
- @headerContent = ();
-}
-
-sub IdlToV8Type
-{
- my $idlType = shift;
- return "v8::Integer" if ($idlType eq "unsigned short");
- return "v8::Integer" if ($idlType eq "short");
- return "v8::Integer" if ($idlType eq "unsigned long");
- return "v8::Integer" if ($idlType eq "long");
- return "v8::String" if ($idlType eq "DOMString");
- return "v8::Boolean" if ($idlType eq "boolean");
- return "v8::Number" if ($idlType eq "double");
- die($idlType);
-}
-
-sub IdlToNativeType
-{
- my $idlType = shift;
-
- return IdlToWrapperType($idlType) if (IsWrapperType($idlType));
-
- return "std::string" if ($idlType eq "DOMString");
- return "bool" if ($idlType eq "boolean");
- return "short" if ($idlType eq "short");
- return "long" if ($idlType eq "long");
- return "unsigned short" if ($idlType eq "unsigned short");
- return "unsigned long" if ($idlType eq "unsigned long");
- return "void" if ($idlType eq "void");
- return "char" if ($idlType eq "byte");
- return "unsigned char" if ($idlType eq "octet");
- return "double" if ($idlType eq "double");
- return "float" if ($idlType eq "float");
- die(${idlType});
-}
-
-sub NativeToHandle
-{
- my $nativeType = shift;
- my $nativeName = shift;
-
- return ("v8::Boolean::New(${nativeName})") if ($nativeType eq "bool");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "double");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "double");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "float");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "short");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "char");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "unsigned short");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "unsigned long");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "unsigned char");
- return ("v8::Number::New(${nativeName})") if ($nativeType eq "long");
- return ("v8::String::New(${nativeName}.c_str())") if ($nativeType eq "std::string");
- return ("v8::Undefined()") if ($nativeType eq "void");
-
- die($nativeType);
-}
-
-sub IdlToWrapperType
-{
- my $idlType = shift;
- return "Arabica::XPath::XPathValue<std::string>" if ($idlType eq "XPathResult");
- return "Arabica::XPath::NodeSet<std::string>" if ($idlType eq "NodeSet");
- return "Arabica::DOM::Node<std::string>" if ($idlType eq "Node");
- return "Arabica::DOM::Element<std::string>" if ($idlType eq "Element");
- return "uscxml::Event" if ($idlType eq "SCXMLEvent");
- return "uscxml::Storage" if ($idlType eq "Storage");
- return "uscxml::ArrayBuffer" if ($idlType eq "ArrayBuffer");
- return "uscxml::ArrayBufferView" if ($idlType eq "ArrayBufferView");
- return "uscxml::Int8Array" if ($idlType eq "Int8Array");
- return "uscxml::Uint8Array" if ($idlType eq "Uint8Array");
- return "uscxml::Uint8ClampedArray" if ($idlType eq "Uint8ClampedArray");
- return "uscxml::Int16Array" if ($idlType eq "Int16Array");
- return "uscxml::Uint16Array" if ($idlType eq "Uint16Array");
- return "uscxml::Int32Array" if ($idlType eq "Int32Array");
- return "uscxml::Uint32Array" if ($idlType eq "Uint32Array");
- return "uscxml::Float32Array" if ($idlType eq "Float32Array");
- return "uscxml::Float64Array" if ($idlType eq "Float64Array");
- return "uscxml::DataView" if ($idlType eq "DataView");
- return "Arabica::DOM::${idlType}<std::string>";
-}
-
-sub IdlToArgHandle
-{
- my $type = shift;
- my $localName = shift;
- my $paramName = shift;
- my $thisType = shift;
-
- return ("v8::String::AsciiValue ${localName}(${paramName});", "*${localName}") if ($type eq "DOMString");
- return ("unsigned long ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned long");
- return ("long ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "long");
- return ("double ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "double");
- return ("float ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "float");
- return ("unsigned short ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned short");
- return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean");
- return ("char ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "byte");
- return ("short ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "short");
- return ("unsigned char ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "octet");
- return ("void* ${localName} = v8::External::Unwrap(${paramName}->ToObject()->GetInternalField(0));", ${localName}) if ($type eq "any");
- return ("std::vector<long> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInteger()->Value());\n}", "${localName}") if ($type eq "long[]");
- return ("std::vector<float> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "float[]");
- return ("std::vector<double> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "double[]");
- return ("std::vector<char> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "byte[]");
- return ("std::vector<short> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "short[]");
- return ("std::vector<unsigned short> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned short[]");
- return ("std::vector<unsigned long> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned long[]");
- return ("std::vector<unsigned char> ${localName};\nv8::Handle<v8::Array> ${localName}Array(v8::Array::Cast(*args[0]));\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "octet[]");
-
- if (IsWrapperType($type)) {
- my $wrapperType = IdlToWrapperType($type);
- if ($type =~ /.*Array$/ or $type =~ /^ArrayBuffer.*/) {
- return ("${wrapperType}* ${localName} = V8DOM::toClassPtr<V8${type}::V8${type}Private >(${paramName}->ToObject()->GetInternalField(0))->nativeObj;", "${localName}");
- }
-
- return ("${wrapperType}* ${localName} = V8DOM::toClassPtr<V8${type}::V8${type}Private >(${paramName}->ToObject()->GetInternalField(0))->nativeObj;", "*${localName}");
- }
-
- print $type."\n";
- die();
-}
-
-sub IdlToTypeChecker
-{
- my $idlType = shift;
- my $attr = shift;
-
- return $attr."->IsString()" if ($idlType eq "DOMString");
- return $attr."->IsBoolean()" if ($idlType eq "boolean");
- return $attr."->IsInt32()" if ($idlType eq "short");
- return $attr."->IsInt32()" if ($idlType eq "long");
- return $attr."->IsArray()" if ($idlType eq "long[]");
- return $attr."->IsUint32()" if ($idlType eq "unsigned short");
- return $attr."->IsUint32()" if ($idlType eq "unsigned long");
- return $attr."->IsInt32()" if ($idlType eq "byte");
- return $attr."->IsUint32()" if ($idlType eq "octet");
- return $attr."->IsNumber()" if ($idlType eq "double");
- return $attr."->IsArray()" if ($idlType eq "double[]");
- return $attr."->IsNumber()" if ($idlType eq "float");
- return $attr."->IsArray()" if ($idlType eq "float[]");
- return $attr."->IsArray()" if ($idlType eq "short[]");
- return $attr."->IsArray()" if ($idlType eq "unsigned short[]");
- return $attr."->IsArray()" if ($idlType eq "unsigned long[]");
- return $attr."->IsArray()" if ($idlType eq "byte[]");
- return $attr."->IsArray()" if ($idlType eq "octet[]");
- return "true" if ($idlType eq "any");
-
- return $attr."->IsObject() && V8".$idlType."::hasInstance(".$attr.")" if (IsWrapperType($idlType));
-
- print $idlType."\n";
- die();
-
-}
-
-sub IdlToWrapperAttrGetter
-{
- my $interface = shift;
- my $attribute = shift;
-
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "size");
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "empty");
- return "asString" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "stringValue");
- return "asBool" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "booleanValue");
- return "asNumber" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "numberValue");
-
- return "get" . ucfirst($attribute->signature->name);
-}
-
-sub IdlToWrapperFunction
-{
- my $interface = shift;
- my $function = shift;
-
- # if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder") {
- # print Dumper($interface);
- # print Dumper($function);
- # }
-
- return "to_document_order" if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder");
-
- return $function->signature->name;
-
-}
-
-sub IdlToWrapperAttrSetter
-{
- my $idlAttr = shift;
- return "set" . ucfirst($idlAttr);
-}
-
-
-sub IsReadonly
-{
- my $attribute = shift;
- my $attrExt = $attribute->signature->extendedAttributes;
- return ($attribute->type =~ /readonly/ || $attrExt->{"V8ReadOnly"}) && !$attrExt->{"Replaceable"};
-}
-
-
-my %non_wrapper_types = (
- 'CompareHow' => 1,
- 'DOMObject' => 1,
- 'DOMString' => 1,
- 'DOMString[]' => 1,
- 'DOMTimeStamp' => 1,
- 'Date' => 1,
- 'Dictionary' => 1,
- 'EventListener' => 1,
- # FIXME: When EventTarget is an interface and not a mixin, fix this so that
- # EventTarget is treated as a wrapper type.
- 'EventTarget' => 1,
- 'IDBKey' => 1,
- 'JSObject' => 1,
- 'MediaQueryListListener' => 1,
- 'NodeFilter' => 1,
- 'any' => 1,
- 'boolean' => 1,
- 'double' => 1,
- 'float' => 1,
- 'int' => 1,
- 'long long' => 1,
- 'long' => 1,
- 'long[]' => 1,
- 'short' => 1,
- 'short[]' => 1,
- 'void' => 1,
- 'byte' => 1,
- 'byte[]' => 1,
- 'octet' => 1,
- 'char' => 1,
- 'float[]' => 1,
- 'float' => 1,
- 'double[]' => 1,
- 'octet[]' => 1,
- 'double' => 1,
- 'unsigned int' => 1,
- 'unsigned long long' => 1,
- 'unsigned long' => 1,
- 'unsigned long[]' => 1,
- 'unsigned short' => 1,
- 'unsigned short[]' => 1
-);
-
-sub IsWrapperType
-{
- my $type = shift;
- return !($non_wrapper_types{$type});
-}
-
-sub GenerateHeaderContentHeader
-{
- my $interface = shift;
- my $v8InterfaceName = "V8" . $interface->name;
- my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
-
- my @headerContentHeader = split("\r", $headerTemplate);
-
- push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString;
- push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h");
- push(@headerContentHeader, "\n#define ${v8InterfaceName}" . "_h\n\n");
- return @headerContentHeader;
-}
-
-1;
diff --git a/contrib/dom/scripts/CodeGeneratorArabicaV8.post3.14.pm b/contrib/dom/scripts/CodeGeneratorArabicaV8.post3.14.pm
deleted file mode 100644
index e913aaa..0000000
--- a/contrib/dom/scripts/CodeGeneratorArabicaV8.post3.14.pm
+++ /dev/null
@@ -1,1021 +0,0 @@
-# Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
-# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
-# Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
-# Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
-# Copyright (C) 2006 Apple Computer, Inc.
-# Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
-# Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
-# Copyright (C) Research In Motion Limited 2010. All rights reserved.
-# Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
-# Copyright (C) 2012 Ericsson AB. All rights reserved.
-# Copyright (C) 2013 Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de>
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public License
-# along with this library; see the file COPYING.LIB. If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-#
-
-package CodeGeneratorArabicaV8;
-
-use strict;
-use Data::Dumper;
-use Carp qw/longmess cluck confess/;
-
-use constant FileNamePrefix => "V8";
-
-my $codeGenerator;
-
-
-my @headerContent = ();
-my @implContentHeader = ();
-my @implContent = ();
-my @implContentDecls = ();
-my %implIncludes = ();
-my %headerIncludes = ();
-
-# Default .h template
-my $headerTemplate = << 'EOF';
-/**
- * @file
- * @author This file has been generated by generate-bindings.pl. DO NOT MODIFY!
- * @copyright Simplified BSD
- *
- * @cond
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the FreeBSD license as published by the FreeBSD
- * project.
- *
- * This program 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.
- *
- * You should have received a copy of the FreeBSD license along with this
- * program. If not, see <http://www.opensource.org/licenses/bsd-license>.
- * @endcond
- */
-
-EOF
-
-# Default constructor
-sub new
-{
- my $object = shift;
- my $reference = { };
-
- $codeGenerator = shift;
-
- bless($reference, $object);
- return $reference;
-}
-
-sub GenerateInterface
-{
- my $object = shift;
- my $interface = shift;
-
-# print Dumper($interface);
-
- # Start actual generation
- if ($interface->extendedAttributes->{"Callback"}) {
- die();
- $object->GenerateCallbackHeader($interface);
- $object->GenerateCallbackImplementation($interface);
- } else {
- $object->GenerateHeader($interface);
- $object->GenerateImplementation($interface);
- }
-}
-
-sub AddToImplIncludes
-{
- my $header = shift;
- my $conditional = shift;
-
- if ($header eq "V8bool.h") {
- confess();
- }
-
- if (not $conditional) {
- $implIncludes{$header} = 1;
- } elsif (not exists($implIncludes{$header})) {
- $implIncludes{$header} = $conditional;
- } else {
- my $oldValue = $implIncludes{$header};
- if ($oldValue ne 1) {
- my %newValue = ();
- $newValue{$conditional} = 1;
- foreach my $condition (split(/\|/, $oldValue)) {
- $newValue{$condition} = 1;
- }
- $implIncludes{$header} = join("|", sort keys %newValue);
- }
- }
-}
-
-sub GenerateHeader
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-# print Dumper($extensions);
-
- # Copy contents of parent interfaces except the first parent.
- my @parents;
- $codeGenerator->AddMethodsConstantsAndAttributesFromParentInterfaces($interface, \@parents, 1);
- $codeGenerator->LinkOverloadedFunctions($interface);
-
- # - Add default header template
- push(@headerContent, GenerateHeaderContentHeader($interface));
-
- $headerIncludes{"string"} = 1;
- $headerIncludes{"uscxml/plugins/datamodel/ecmascript/v8/V8DOM.h"} = 1;
- $headerIncludes{"DOM/Node.hpp"} = 1;
- $headerIncludes{"v8.h"} = 1;
-
- if ($interfaceName =~ /.*Array$/ or $interfaceName =~ /^ArrayBuffer.*/) {
- $headerIncludes{"../../TypedArray.h"} = 1;
- }
-
- foreach (@{$interface->parents}) {
- my $parent = $_;
- $headerIncludes{"V8${parent}.h"} = 1;
- }
-
- push(@headerContent, "#include \<string\>\n");
- foreach my $headerInclude (sort keys(%headerIncludes)) {
- if ($headerInclude =~ /wtf|v8\.h/) {
- push(@headerContent, "#include \<${headerInclude}\>\n");
- } else {
- push(@headerContent, "#include \"${headerInclude}\"\n");
- }
- }
-
- push(@headerContent, "");
- push(@headerContent, "\nnamespace Arabica {");
- push(@headerContent, "\nnamespace DOM {\n");
-
- push(@headerContent, "\nclass V8${interfaceName} {");
- push(@headerContent, "\npublic:");
-
- my $wrapperType = IdlToWrapperType($interfaceName);
- push(@headerContent, <<END);
-
- struct V8${interfaceName}Private {
- V8DOM* dom;
- ${wrapperType}* nativeObj;
- };
-END
-
- if ($extensions->{'DontDestroyWrapped'}) {
- push(@headerContent, "\n V8_DESTRUCTOR_KEEP_WRAPPED(V8${interfaceName}Private);");
- } else {
- push(@headerContent, "\n V8_DESTRUCTOR(V8${interfaceName}Private);");
- }
- push(@headerContent, "\n static bool hasInstance(v8::Handle<v8::Value>);");
- push(@headerContent, "\n");
-
- # callbacks for actual functions
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- next if (exists $generated{"${name}${custom}Callback"});
- push(@headerContent, "\n static void ${name}${custom}Callback(const v8::FunctionCallbackInfo<v8::Value>&);");
- $generated{"${name}${custom}Callback"} = 1;
- }
- push(@headerContent, "\n");
-
- # attribute getter and setters
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- push(@headerContent, "\n static void ${name}${customGetter}AttrGetter(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info);");
- if (!IsReadonly($attribute)) {
- push(@headerContent, "\n static void ${name}${customSetter}AttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info);");
- }
- }
-
- if ($extensions->{'CustomIndexedGetter'}) {
- push(@headerContent, "\n static void indexedPropertyCustomGetter(uint32_t, const v8::PropertyCallbackInfo<v8::Value>&);");
- }
- if ($extensions->{'CustomIndexedSetter'}) {
- push(@headerContent, "\n static void indexedPropertyCustomSetter(uint32_t, v8::Local<v8::Value>, const v8::PropertyCallbackInfo<v8::Value>&);");
- }
- push(@headerContent, "\n");
-
- GenerateClassPrototypeHeader($interface);
-
- push(@headerContent, "\n};\n\n}\n}\n\n");
- push(@headerContent, "#endif // V8${interfaceName}" . "_h\n");
-
-}
-
-#
-# Write class template prototype constructor
-#
-sub GenerateClassPrototypeHeader
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- if ($extensions->{'Constructors'}) {
-
- push(@headerContent, "\n");
- push(@headerContent, " static void constructor(const v8::FunctionCallbackInfo<v8::Value>&);\n");
- push(@headerContent, <<END);
- static v8::Handle<v8::FunctionTemplate> getConstructor(v8::Isolate* isolate) {
- return v8::FunctionTemplate::New(isolate, constructor);
- }
-END
- }
-
- push(@headerContent, <<END);
- static v8::Handle<v8::FunctionTemplate> getTmpl(v8::Isolate* isolate) {
- v8::Handle<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New(isolate);
- tmpl->SetClassName(v8::String::NewFromUtf8(isolate, "${interfaceName}"));
- tmpl->ReadOnlyPrototype();
-
- v8::Local<v8::ObjectTemplate> instance = tmpl->InstanceTemplate();
- v8::Local<v8::ObjectTemplate> prototype = tmpl->PrototypeTemplate();
- (void)prototype; // surpress unused warnings
-
- instance->SetInternalFieldCount(1);
-END
-
- push(@headerContent, "\n");
- foreach my $attribute (@{$interface->attributes}) {
- my $name = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
- my $customGetter = ($attrExt->{'CustomGetter'} ? "Custom" : "");
- my $customSetter = ($attrExt->{'CustomSetter'} ? "Custom" : "");
- my $getter = "V8${interfaceName}::${name}${customGetter}AttrGetter";
- my $setter = (IsReadonly($attribute) ? "0" : "V8${interfaceName}::${name}${customSetter}AttrSetter");
- push(@headerContent, <<END);
- instance->SetAccessor(v8::String::NewFromUtf8(isolate, "${name}"), ${getter}, ${setter},
- v8::External::New(isolate, 0), static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None));
-END
- }
-
- if ($extensions->{'CustomIndexedGetter'} || $extensions->{'CustomIndexedSetter'}) {
- my $indexedGetter = ($extensions->{'CustomIndexedGetter'} ? "V8${interfaceName}::indexedPropertyCustomGetter" : 0);
- my $indexedSetter = ($extensions->{'CustomIndexedSetter'} ? "V8${interfaceName}::indexedPropertyCustomSetter" : 0);
- push(@headerContent, "\n instance->SetIndexedPropertyHandler(${indexedGetter}, ${indexedSetter});");
- }
-
- push(@headerContent, "\n");
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $custom = ($attrExt->{'Custom'} ? "Custom" : "");
- next if (exists $generated{"${name}"});
- $generated{"${name}"} = 1;
- push(@headerContent, <<END);
- prototype->Set(v8::String::NewFromUtf8(isolate, "${name}"),
- v8::FunctionTemplate::New(isolate, V8${interfaceName}::${name}${custom}Callback, v8::Undefined(isolate)), static_cast<v8::PropertyAttribute>(v8::DontDelete));
-END
- }
-
- push(@headerContent, "\n");
- foreach my $constant (@{$interface->constants}) {
- my $name = $constant->name;
- my $value = $constant->value;
- my $type = IdlToV8Type($constant->type);
- push(@headerContent, <<END);
- tmpl->Set(v8::String::NewFromUtf8(isolate, "${name}"), ${type}::New(isolate, ${value}), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
- prototype->Set(v8::String::NewFromUtf8(isolate, "${name}"), ${type}::New(isolate, ${value}), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontEnum));
-END
- }
-
- push(@headerContent, "\n");
- if (@{$interface->parents}) {
- my $parent = @{$interface->parents}[0];
- push(@headerContent, " tmpl->Inherit(V8${parent}::getTmpl(isolate));\n");
- }
- push(@headerContent, <<END);
- return tmpl;
- }
-
-END
-
-}
-
-sub GenerateImplementationAttributes
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $extensions = $interface->extendedAttributes;
-
- # Generate property accessors for attributes.
- for (my $index = 0; $index < @{$interface->attributes}; $index++) {
- my $attribute = @{$interface->attributes}[$index];
- my $attrType = $attribute->signature->type;
- my $attrName = $attribute->signature->name;
- my $attrExt = $attribute->signature->extendedAttributes;
-
- my $wrapperRetType = IdlToWrapperType($attrType);
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $wrapperGetter;
-
- if ($attrExt->{'AttributeIsPublic'} || $extensions->{'AttributesArePublic'}) {
- $wrapperGetter = $attrName;
- } else {
- $wrapperGetter = IdlToWrapperAttrGetter($interface, $attribute)."()";
-
- }
-
- # getter
- if (!$attrExt->{'CustomGetter'}) {
- push(@implContent, <<END);
-
- void V8${interfaceName}::${attrName}AttrGetter(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::Isolate* isolate = info.GetIsolate();
- v8::Local<v8::Object> self = info.Holder();
- struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));
-END
- if (IsWrapperType($attrType)) {
- AddToImplIncludes("V8".$attrType.".h");
- push(@implContent, "\n ".GenerateConditionalUndefReturn($interface, $attribute, "privData->nativeObj->${wrapperGetter}"));
-
- push(@implContent, <<END);
-
- ${wrapperRetType}* arbaicaRet = new ${wrapperRetType}(privData->nativeObj->${wrapperGetter});
-
- v8::Handle<v8::Function> arbaicaRetCtor = V8${attrType}::getTmpl(isolate)->GetFunction();
- v8::Persistent<v8::Object> arbaicaRetObj(isolate, arbaicaRetCtor->NewInstance());
-
- struct V8${attrType}::V8${attrType}Private* retPrivData = new V8${attrType}::V8${attrType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = arbaicaRet;
-
- arbaicaRetObj.Get(isolate)->SetInternalField(0, V8DOM::toExternal(retPrivData));
- arbaicaRetObj.SetWeak<V8${attrType}::V8${attrType}Private>(0, V8${attrType}::jsDestructor);
- info.GetReturnValue().Set(arbaicaRetObj);
- // return arbaicaRetObj;
-END
- } else {
- my $v8Type = IdlToV8Type($attrType);
- if ($attrType eq "DOMString") {
- if ($attrExt->{'EmptyAsNull'}) {
- push(@implContent, "\n if (privData->nativeObj->${wrapperGetter}.length() == 0)");
- push(@implContent, "\n return; //v8::Undefined(isolate);");
- }
- push(@implContent, "\n info.GetReturnValue().Set(${v8Type}::NewFromUtf8(isolate, privData->nativeObj->${wrapperGetter}.c_str()));");
- # push(@implContent, "\n return ${v8Type}::New(privData->nativeObj->${wrapperGetter}.c_str());");
- } else {
- push(@implContent, "\n info.GetReturnValue().Set(${v8Type}::New(isolate, privData->nativeObj->${wrapperGetter}));");
- }
- }
- push(@implContent, "\n }\n");
- }
-
- if (!$attrExt->{'CustomSetter'}) {
- # setter
- if (!IsReadonly($attribute)) {
- my $wrapperSetter = IdlToWrapperAttrSetter($attrName);
- push(@implContent, "\n void V8${interfaceName}::${attrName}AttrSetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) {");
- push(@implContent, "\n v8::Isolate* isolate = info.GetIsolate();");
- push(@implContent, "\n v8::Local<v8::Object> self = info.Holder();");
- push(@implContent, "\n struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));");
-
- my ($handle, $deref) = IdlToArgHandle($attribute->signature->type, "local".ucfirst($attribute->signature->name), "value", $interfaceName);
-
- push(@implContent, "\n $handle");
- push(@implContent, "\n privData->nativeObj->${wrapperSetter}(${deref});");
- push(@implContent, "\n }\n");
-
- }
- }
- }
-}
-
-sub GenerateConditionalUndefReturn
-{
- my $interface = shift;
- my $attribute = shift;
- my $getterExpression = shift;
-
- return "" if ($attribute->signature->type eq "NamedNodeMap");
- return "" if ($attribute->signature->type eq "NodeList");
- return "if (!$getterExpression) return; //v8::Undefined(isolate);";
-}
-
-sub GenerateConstructor
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
- if ($extensions->{'Constructors'}) {
-
- push(@implContent, "\n void V8${interfaceName}::constructor(const v8::FunctionCallbackInfo<v8::Value>& info) {");
- push(@implContent, <<END);
-
- v8::Isolate* isolate = info.GetIsolate();
- if (!info.IsConstructCall()) {
- isolate->ThrowException(v8::String::NewFromUtf8(isolate, "Cannot call constructor as function"));
- return;
- }
-END
-
- push(@implContent, "\n ".IdlToWrapperType($interfaceName)."* localInstance = NULL;");
- # dispatch the actual constructor
- push(@implContent, "\n if (false) {\n}");
- my @variants;
- foreach my $fullCons (@{$extensions->{'Constructors'}}) {
- push (@variants, $fullCons);
-
- for (my $i = @{$fullCons}; $i > 0; $i--) {
- my $variant = @{$fullCons}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$fullCons}[$j]);
- }
- push (@variants, $slice);
- }
- }
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
- }
- foreach my $constructor (@variants) {
- push(@implContent, " else if (info.Length() == " . @{$constructor});
-
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- AddToImplIncludes("V8".$type.".h") if (IsWrapperType($type));
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "info[$i]"));
-
- }
- push(@implContent, ") {\n");
- my $constructorArgs;
- my $constructorSep = "";
- for (my $i = 0; $i < @{$constructor}; $i++) {
- my $type = $constructor->[$i]->{'domSignature::type'};
- my $name = $constructor->[$i]->{'domSignature::name'};
- my ($handle, $deref) = IdlToArgHandle($type, "local".ucfirst($name), "info[$i]", $interfaceName);
- $constructorArgs .= ${constructorSep}.${deref};
- $constructorSep = ", ";
- push(@implContent, "\n $handle");
-
- }
- push(@implContent, "\n localInstance = new ".IdlToWrapperType($interfaceName)."(${constructorArgs});");
- push(@implContent, "\n\n }");
- }
- push(@implContent, "\n");
-
- push(@implContent, <<END);
- if (!localInstance) {
- throw V8Exception("Parameter mismatch while calling constructor for ${interfaceName}");
- }
-
- v8::Handle<v8::Function> retCtor = V8${interfaceName}::getTmpl(isolate)->GetFunction();
- v8::Persistent<v8::Object> retObj(isolate, retCtor->NewInstance());
-
- struct V8${interfaceName}::V8${interfaceName}Private* retPrivData = new V8${interfaceName}::V8${interfaceName}Private();
- retPrivData->nativeObj = localInstance;
-
- retObj.Get(isolate)->SetInternalField(0, V8DOM::toExternal(retPrivData));
- retObj.SetWeak<V8${interfaceName}::V8${interfaceName}Private>(0, V8${interfaceName}::jsDestructor);
-
- info.GetReturnValue().Set(retObj);
- return;
- }
-END
- }
-
-}
-
-sub GenerateImplementationFunctionCallbacks
-{
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
-
- # Generate methods for functions.
- my %generated;
- foreach my $function (@{$interface->functions}) {
- my $name = $function->signature->name;
- my $attrExt = $function->signature->extendedAttributes;
- my $retType = $function->signature->type;
- my $wrapperRetType = IdlToWrapperType($retType);
-
- next if ($attrExt->{'Custom'});
- next if (exists $generated{"${name}Callback"});
- $generated{"${name}Callback"} = 1;
-
- # get all functions with this name
- my @sameFunctions = grep($_->signature->name eq $name, @{$interface->functions});
-
- # signature
- push(@implContent, <<END);
-
- void V8${interfaceName}::${name}Callback(const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Isolate* isolate = info.GetIsolate();
-END
-
- # get this
- push(@implContent, "\n v8::Local<v8::Object> self = info.Holder();");
- push(@implContent, "\n struct V8${interfaceName}Private* privData = V8DOM::toClassPtr<V8${interfaceName}Private >(self->GetInternalField(0));");
-
- # establish all variants
- my @variants;
- foreach my $functionVar (@sameFunctions) {
- push (@variants, $functionVar->parameters);
-
- for (my $i = @{$functionVar->parameters}; $i > 0; $i--) {
- my $variant = @{$functionVar->parameters}[$i];
- if ($variant->{'domSignature::isOptional'}) {
- my $slice;
- for (my $j = 0; $j < $i; $j++) {
- push(@{$slice}, @{$functionVar->parameters}[$j]);
- }
- push (@variants, $slice);
- }
- }
- }
-
- # arguments to local handles
- push(@implContent, "\n if (false) {");
-
- # sort to put most determinate signatures first
- @variants = sort {
- if (@{$b} != @{$a}) {
- # more arguments are more determinant
- @{$b} <=> @{$a};
- } else {
- my @aWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$a});
- my @bWrap = grep(IsWrapperType($_->{'domSignature::type'}), @{$b});
- @bWrap <=> @aWrap;
- }
- } @variants;
-
- foreach my $variant (@variants) {
- my $parameterIndex = 0;
- my @argList;
-
- push(@implContent, "\n } else if (info.Length() == " . @{$variant});
- for (my $i = 0; $i < @{$variant}; $i++) {
- my $type = $variant->[$i]->{'domSignature::type'};
- push(@implContent, " &&\n " . IdlToTypeChecker($type, "info[$i]"));
- }
- push(@implContent, ")\n {");
- foreach my $parameter (@{$variant}) {
- my $value = "info[$parameterIndex]";
- my $type = $parameter->type;
- AddToImplIncludes("V8".$type.".h") if (IsWrapperType($type));
-
- my ($handle, $deref) = IdlToArgHandle($parameter->type, "local".ucfirst($parameter->name), "info[${parameterIndex}]", $interfaceName);
- push(@implContent, "\n ${handle}");
- push(@argList, $deref);
- $parameterIndex++;
- }
-
- # invoke native function with argument handles
- my $retNativeType = IdlToNativeType($retType);
- my $wrapperFunctionName = IdlToWrapperFunction($interface, $function);
- if (IsWrapperType($retType)) {
- push(@implContent, "\n\n ${retNativeType}* retVal = new $wrapperRetType(privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . "));\n");
- } elsif ($retNativeType eq "void") {
- push(@implContent, "\n\n privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- } else {
- push(@implContent, "\n\n ${retNativeType} retVal = privData->nativeObj->${wrapperFunctionName}(" . join(", ", @argList) . ");\n");
- }
-
- # wrap return type if needed
- if (IsWrapperType($retType)) {
- AddToImplIncludes("V8".$retType.".h");
-
- push(@implContent, <<END);
- v8::Handle<v8::Function> retCtor = V8${retType}::getTmpl(isolate)->GetFunction();
- v8::Persistent<v8::Object> retObj(isolate, retCtor->NewInstance());
-
- struct V8${retType}::V8${retType}Private* retPrivData = new V8${retType}::V8${retType}Private();
- retPrivData->dom = privData->dom;
- retPrivData->nativeObj = retVal;
-
- retObj.Get(isolate)->SetInternalField(0, V8DOM::toExternal(retPrivData));
- retObj.SetWeak<V8${retType}::V8${retType}Private>(0, V8${retType}::jsDestructor);
- info.GetReturnValue().Set(retObj);
- //return retObj;
-END
- } else {
- my $toHandleString = NativeToHandle($retNativeType, "retVal");
- push(@implContent, "\n info.GetReturnValue().Set(${toHandleString});");
- }
- }
- push(@implContent, <<END);
-
- }
- throw V8Exception("Parameter mismatch while calling ${name}");
- // return v8::Undefined(isolate);
- }
-END
- }
-
-}
-
-sub GenerateImplementation
-{
- my $object = shift;
- my $interface = shift;
- my $interfaceName = $interface->name;
- my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($interface);
- my $v8InterfaceName = "V8$interfaceName";
- my $wrapperType = IdlToWrapperType($interfaceName);
- my $extensions = $interface->extendedAttributes;
-
- AddToImplIncludes("V8${interfaceName}.h");
-
- # Find the super descriptor.
- my $parentClass = "";
- my $parentClassTemplate = "";
- foreach (@{$interface->parents}) {
- my $parent = $_;
- AddToImplIncludes("V8${parent}.h");
- $parentClass = "V8" . $parent;
- last;
- }
-
- push(@implContent, "namespace Arabica {\n");
- push(@implContent, "namespace DOM {\n\n");
-
- if ($extensions->{'Constructors'}) {
- GenerateConstructor($interface);
- }
-
- GenerateImplementationAttributes($interface);
- GenerateImplementationFunctionCallbacks($interface);
-
-
- push(@implContent, <<END);
- bool V8${interfaceName}::hasInstance(v8::Handle<v8::Value> value) {
- return getTmpl(v8::Isolate::GetCurrent())->HasInstance(value);
- }
-
-}
-}
-END
-
- # We've already added the header for this file in implContentHeader, so remove
- # it from implIncludes to ensure we don't #include it twice.
-# delete $implIncludes{"${v8InterfaceName}.h"};
-}
-
-sub WriteData
-{
- my $object = shift;
- my $interface = shift;
- my $outputDir = shift;
- my $outputHeadersDir = shift;
-
- my $name = $interface->name;
- my $prefix = FileNamePrefix;
- my $headerFileName = "$outputHeadersDir/$prefix$name.h";
- my $implFileName = "$outputDir/$prefix$name.cpp";
-
- # print "WriteData\n";
- # print Dumper($interface);
- # exit();
-
- # Update a .cpp file if the contents are changed.
- my $contents = $headerTemplate;
- $contents .= join "", @implContentHeader;
-
- my @includes = ();
- my %implIncludeConditions = ();
- foreach my $include (keys %implIncludes) {
- my $condition = $implIncludes{$include};
- my $checkType = $include;
- $checkType =~ s/\.h//;
- next if $codeGenerator->IsSVGAnimatedType($checkType);
-
- if ($include =~ /wtf/) {
- $include = "\<$include\>";
- } else {
- $include = "\"$include\"";
- }
-
- if ($condition eq 1) {
- push @includes, $include;
- } else {
- push @{$implIncludeConditions{$condition}}, $include;
- }
- }
- foreach my $include (sort @includes) {
- $contents .= "#include $include\n";
- }
- foreach my $condition (sort keys %implIncludeConditions) {
- $contents .= "\n#if " . $codeGenerator->GenerateConditionalStringFromAttributeValue($condition) . "\n";
- foreach my $include (sort @{$implIncludeConditions{$condition}}) {
- $contents .= "#include $include\n";
- }
- $contents .= "#endif\n";
- }
-
- $contents .= "\n";
- $contents .= join "", @implContentDecls, @implContent;
- $codeGenerator->UpdateFile($implFileName, $contents);
-
- %implIncludes = ();
- @implContentHeader = ();
- @implContentDecls = ();
- @implContent = ();
-
- # Update a .h file if the contents are changed.
- $contents = join "", @headerContent;
- $codeGenerator->UpdateFile($headerFileName, $contents);
-
- @headerContent = ();
-}
-
-sub IdlToV8Type
-{
- my $idlType = shift;
- return "v8::Integer" if ($idlType eq "unsigned short");
- return "v8::Integer" if ($idlType eq "short");
- return "v8::Integer" if ($idlType eq "unsigned long");
- return "v8::Integer" if ($idlType eq "long");
- return "v8::String" if ($idlType eq "DOMString");
- return "v8::Boolean" if ($idlType eq "boolean");
- return "v8::Number" if ($idlType eq "double");
- die($idlType);
-}
-
-sub IdlToNativeType
-{
- my $idlType = shift;
-
- return IdlToWrapperType($idlType) if (IsWrapperType($idlType));
-
- return "std::string" if ($idlType eq "DOMString");
- return "bool" if ($idlType eq "boolean");
- return "short" if ($idlType eq "short");
- return "long" if ($idlType eq "long");
- return "unsigned short" if ($idlType eq "unsigned short");
- return "unsigned long" if ($idlType eq "unsigned long");
- return "void" if ($idlType eq "void");
- return "char" if ($idlType eq "byte");
- return "unsigned char" if ($idlType eq "octet");
- return "double" if ($idlType eq "double");
- return "float" if ($idlType eq "float");
- die(${idlType});
-}
-
-sub NativeToHandle
-{
- my $nativeType = shift;
- my $nativeName = shift;
-
- return ("v8::Boolean::New(isolate, ${nativeName})") if ($nativeType eq "bool");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "double");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "double");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "float");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "short");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "char");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "unsigned short");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "unsigned long");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "unsigned char");
- return ("v8::Number::New(isolate, ${nativeName})") if ($nativeType eq "long");
- return ("v8::String::NewFromUtf8(isolate, ${nativeName}.c_str())") if ($nativeType eq "std::string");
- return ("v8::Undefined(isolate)") if ($nativeType eq "void");
-
- die($nativeType);
-}
-
-sub IdlToWrapperType
-{
- my $idlType = shift;
- return "Arabica::XPath::XPathValue<std::string>" if ($idlType eq "XPathResult");
- return "Arabica::XPath::NodeSet<std::string>" if ($idlType eq "NodeSet");
- return "Arabica::DOM::Node<std::string>" if ($idlType eq "Node");
- return "Arabica::DOM::Element<std::string>" if ($idlType eq "Element");
- return "uscxml::Event" if ($idlType eq "SCXMLEvent");
- return "uscxml::Storage" if ($idlType eq "Storage");
- return "uscxml::ArrayBuffer" if ($idlType eq "ArrayBuffer");
- return "uscxml::ArrayBufferView" if ($idlType eq "ArrayBufferView");
- return "uscxml::Int8Array" if ($idlType eq "Int8Array");
- return "uscxml::Uint8Array" if ($idlType eq "Uint8Array");
- return "uscxml::Uint8ClampedArray" if ($idlType eq "Uint8ClampedArray");
- return "uscxml::Int16Array" if ($idlType eq "Int16Array");
- return "uscxml::Uint16Array" if ($idlType eq "Uint16Array");
- return "uscxml::Int32Array" if ($idlType eq "Int32Array");
- return "uscxml::Uint32Array" if ($idlType eq "Uint32Array");
- return "uscxml::Float32Array" if ($idlType eq "Float32Array");
- return "uscxml::Float64Array" if ($idlType eq "Float64Array");
- return "uscxml::DataView" if ($idlType eq "DataView");
- return "Arabica::DOM::${idlType}<std::string>";
-}
-
-sub IdlToArgHandle
-{
- my $type = shift;
- my $localName = shift;
- my $paramName = shift;
- my $thisType = shift;
-
- return ("v8::String::Utf8Value ${localName}(${paramName});", "*${localName}") if ($type eq "DOMString");
- return ("unsigned long ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned long");
- return ("long ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "long");
- return ("double ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "double");
- return ("float ${localName} = ${paramName}->ToNumber()->Value();", ${localName}) if ($type eq "float");
- return ("unsigned short ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "unsigned short");
- return ("bool ${localName} = ${paramName}->ToBoolean()->BooleanValue();", ${localName}) if ($type eq "boolean");
- return ("char ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "byte");
- return ("short ${localName} = ${paramName}->ToNumber()->Int32Value();", ${localName}) if ($type eq "short");
- return ("unsigned char ${localName} = ${paramName}->ToNumber()->Uint32Value();", ${localName}) if ($type eq "octet");
- # return ("void* ${localName} = v8::External::Unwrap(${paramName}->ToObject()->GetInternalField(0));", ${localName}) if ($type eq "any");
- return ("void* ${localName} = v8::Handle<v8::External>::Cast(${paramName}->ToObject()->GetInternalField(0))->Value();", ${localName}) if ($type eq "any");
- return ("std::vector<long> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInteger()->Value());\n}", "${localName}") if ($type eq "long[]");
- return ("std::vector<float> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "float[]");
- return ("std::vector<double> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToNumber()->Value());\n}", "${localName}") if ($type eq "double[]");
- return ("std::vector<char> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "byte[]");
- return ("std::vector<short> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToInt32()->Value());\n}", "${localName}") if ($type eq "short[]");
- return ("std::vector<unsigned short> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned short[]");
- return ("std::vector<unsigned long> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "unsigned long[]");
- return ("std::vector<unsigned char> ${localName};\nv8::Handle<v8::Array> ${localName}Array = v8::Array::New(isolate, v8::Array::Cast(*info[0])->Length());\nfor (int i = 0; i < ${localName}Array->Length(); i++) {\n ${localName}.push_back(${localName}Array->Get(i)->ToUint32()->Value());\n}", "${localName}") if ($type eq "octet[]");
-
- if (IsWrapperType($type)) {
- my $wrapperType = IdlToWrapperType($type);
- if ($type =~ /.*Array$/ or $type =~ /^ArrayBuffer.*/) {
- return ("${wrapperType}* ${localName} = V8DOM::toClassPtr<V8${type}::V8${type}Private >(${paramName}->ToObject()->GetInternalField(0))->nativeObj;", "${localName}");
- }
-
- return ("${wrapperType}* ${localName} = V8DOM::toClassPtr<V8${type}::V8${type}Private >(${paramName}->ToObject()->GetInternalField(0))->nativeObj;", "*${localName}");
- }
-
- print $type."\n";
- die();
-}
-
-sub IdlToTypeChecker
-{
- my $idlType = shift;
- my $attr = shift;
-
- return $attr."->IsString()" if ($idlType eq "DOMString");
- return $attr."->IsBoolean()" if ($idlType eq "boolean");
- return $attr."->IsInt32()" if ($idlType eq "short");
- return $attr."->IsInt32()" if ($idlType eq "long");
- return $attr."->IsArray()" if ($idlType eq "long[]");
- return $attr."->IsUint32()" if ($idlType eq "unsigned short");
- return $attr."->IsUint32()" if ($idlType eq "unsigned long");
- return $attr."->IsInt32()" if ($idlType eq "byte");
- return $attr."->IsUint32()" if ($idlType eq "octet");
- return $attr."->IsNumber()" if ($idlType eq "double");
- return $attr."->IsArray()" if ($idlType eq "double[]");
- return $attr."->IsNumber()" if ($idlType eq "float");
- return $attr."->IsArray()" if ($idlType eq "float[]");
- return $attr."->IsArray()" if ($idlType eq "short[]");
- return $attr."->IsArray()" if ($idlType eq "unsigned short[]");
- return $attr."->IsArray()" if ($idlType eq "unsigned long[]");
- return $attr."->IsArray()" if ($idlType eq "byte[]");
- return $attr."->IsArray()" if ($idlType eq "octet[]");
- return "true" if ($idlType eq "any");
-
- return $attr."->IsObject() && V8".$idlType."::hasInstance(".$attr.")" if (IsWrapperType($idlType));
-
- print $idlType."\n";
- die();
-
-}
-
-sub IdlToWrapperAttrGetter
-{
- my $interface = shift;
- my $attribute = shift;
-
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "size");
- return $attribute->signature->name if ($interface->name eq "NodeSet" && $attribute->signature->name eq "empty");
- return "asString" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "stringValue");
- return "asBool" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "booleanValue");
- return "asNumber" if ($interface->name eq "XPathResult" && $attribute->signature->name eq "numberValue");
-
- return "get" . ucfirst($attribute->signature->name);
-}
-
-sub IdlToWrapperFunction
-{
- my $interface = shift;
- my $function = shift;
-
- # if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder") {
- # print Dumper($interface);
- # print Dumper($function);
- # }
-
- return "to_document_order" if ($interface->name eq "NodeSet" && $function->signature->name eq "toDocumentOrder");
-
- return $function->signature->name;
-
-}
-
-sub IdlToWrapperAttrSetter
-{
- my $idlAttr = shift;
- return "set" . ucfirst($idlAttr);
-}
-
-
-sub IsReadonly
-{
- my $attribute = shift;
- my $attrExt = $attribute->signature->extendedAttributes;
- return ($attribute->type =~ /readonly/ || $attrExt->{"V8ReadOnly"}) && !$attrExt->{"Replaceable"};
-}
-
-
-my %non_wrapper_types = (
- 'CompareHow' => 1,
- 'DOMObject' => 1,
- 'DOMString' => 1,
- 'DOMString[]' => 1,
- 'DOMTimeStamp' => 1,
- 'Date' => 1,
- 'Dictionary' => 1,
- 'EventListener' => 1,
- # FIXME: When EventTarget is an interface and not a mixin, fix this so that
- # EventTarget is treated as a wrapper type.
- 'EventTarget' => 1,
- 'IDBKey' => 1,
- 'JSObject' => 1,
- 'MediaQueryListListener' => 1,
- 'NodeFilter' => 1,
- 'any' => 1,
- 'boolean' => 1,
- 'double' => 1,
- 'float' => 1,
- 'int' => 1,
- 'long long' => 1,
- 'long' => 1,
- 'long[]' => 1,
- 'short' => 1,
- 'short[]' => 1,
- 'void' => 1,
- 'byte' => 1,
- 'byte[]' => 1,
- 'octet' => 1,
- 'char' => 1,
- 'float[]' => 1,
- 'float' => 1,
- 'double[]' => 1,
- 'octet[]' => 1,
- 'double' => 1,
- 'unsigned int' => 1,
- 'unsigned long long' => 1,
- 'unsigned long' => 1,
- 'unsigned long[]' => 1,
- 'unsigned short' => 1,
- 'unsigned short[]' => 1
-);
-
-sub IsWrapperType
-{
- my $type = shift;
- return !($non_wrapper_types{$type});
-}
-
-sub GenerateHeaderContentHeader
-{
- my $interface = shift;
- my $v8InterfaceName = "V8" . $interface->name;
- my $conditionalString = $codeGenerator->GenerateConditionalString($interface);
-
- my @headerContentHeader = split("\r", $headerTemplate);
-
- push(@headerContentHeader, "\n#if ${conditionalString}\n") if $conditionalString;
- push(@headerContentHeader, "\n#ifndef ${v8InterfaceName}" . "_h");
- push(@headerContentHeader, "\n#define ${v8InterfaceName}" . "_h\n\n");
- return @headerContentHeader;
-}
-
-1;
diff --git a/contrib/dom/scripts/IDLAttributes.txt b/contrib/dom/scripts/IDLAttributes.txt
deleted file mode 100644
index e18b311..0000000
--- a/contrib/dom/scripts/IDLAttributes.txt
+++ /dev/null
@@ -1,126 +0,0 @@
-#
-# This file describes all IDL attributes.
-# If any IDL file uses an IDL attribute not listed below, the WebKit build will fail.
-# If you want to add a new IDL attribute, you need to
-# (1) add the IDL attribute to this file
-# (2) add the explanation to the WebKit IDL document (https://trac.webkit.org/wiki/WebKitIDL)
-# (3) add test cases to run-bindings-tests
-#
-# The syntax of this file is as follows:
-# - You can write one IDL attribute per one line.
-# - "ATTR" means that the IDL attribute ATTR does not take any argument; i.e. [ATTR].
-# - "ATTR=X" means that the IDL attribute ATTR always takes one argument X; i.e. [ATTR=X].
-# - "ATTR=X|Y|Z" means that the IDL attribute ATTR takes one or more arguments
-# and the arguments are X, Y or Z; e.g. [ATTR=X], [ATTR=Y], [ATTR=X|Z], [ATTR=X|Y|Z].
-# - "ATTR=|X|Y|Z" means that the IDL attribute ATTR can take arguments
-# and the arguments are X, Y or Z; e.g. [ATTR], [ATTR=X], [ATTR=Y], [ATTR=X|Z], [ATTR=X|Y|Z].
-# - "ATTR=*" means that the IDL attribute ATTR can take arbitrary arguments;
-# e.g. [ATTR=INDEXED_DATABASE], [ATTR=deleteFunction].
-#
-
-ActiveDOMObject
-CPPPureInterface
-CachedAttribute
-CallWith=ScriptExecutionContext|ScriptState|ScriptArguments|CallStack
-Callback
-CheckSecurity
-CheckSecurityForNode
-Clamp
-Conditional=*
-Constructor
-ConstructorParameters=*
-ConstructorRaisesException
-ConstructorTemplate=Event|TypedArray
-Custom
-CustomCall
-CustomConstructor
-CustomDeleteProperty
-CustomEnumerateProperty
-CustomGetOwnPropertySlot
-CustomGetter
-CustomIndexedSetter
-CustomIsReachable
-CustomNamedGetter
-CustomNamedSetter
-CustomPutFunction
-CustomReturn
-CustomSetter
-CustomToJSObject
-Deletable
-DoNotCheckConstants
-DoNotCheckSecurity
-DoNotCheckSecurityOnGetter
-DoNotCheckSecurityOnSetter
-EventTarget
-ExtendsDOMGlobalObject
-GenerateIsReachable=ImplDocument|ImplElementRoot|ImplOwnerNodeRoot
-Immutable
-ImplementedAs=*
-IndexedGetter
-InitializedByEventConstructor
-InterfaceName=*
-IsIndex
-IsWorkerContext
-JSCustom
-JSCustomConstructor
-JSCustomDefineOwnProperty
-JSCustomDefineOwnPropertyOnPrototype
-JSCustomFinalize
-JSCustomGetOwnPropertySlotAndDescriptor
-JSCustomGetter
-JSCustomHeader
-JSCustomIsReachable
-JSCustomMarkFunction
-JSCustomNamedGetterOnPrototype
-JSCustomPushEventHandlerScope
-JSCustomSetter
-JSCustomToJSObject
-JSCustomToNativeObject
-JSGenerateIsReachable=|Impl|ImplContext|ImplDocument|ImplElementRoot|ImplFrame|ImplOwnerNodeRoot
-JSGenerateToJSObject
-JSGenerateToNativeObject
-JSInlineGetOwnPropertySlot
-JSLegacyParent=*
-JSNoStaticTables
-JSWindowEventListener
-MasqueradesAsUndefined
-NamedConstructor=*
-NamedGetter
-NotEnumerable
-NumericIndexedGetter
-ObjCCustomImplementation
-ObjCLegacyUnnamedParameters
-ObjCPolymorphic
-ObjCProtocol
-OmitConstructor
-Optional=|DefaultIsNullString|DefaultIsUndefined
-PassThisToCallback=*
-Reflect=*
-Replaceable
-ReplaceableConstructor
-ReturnNewObject
-StrictTypeChecking
-Supplemental=*
-SuppressToJSObject
-TransferList=*
-TreatNullAs=NullString
-TreatReturnedNullStringAs=Null|Undefined
-TreatUndefinedAs=NullString
-TypedArray=*
-URL
-V8CacheAttributeForGC
-V8Custom
-V8CustomConstructor
-V8CustomGetter
-V8CustomIsReachable
-V8CustomSetter
-V8CustomToJSObject
-V8DependentLifetime
-V8DoNotCheckSignature
-V8EnabledAtRuntime=*
-V8EnabledPerContext=*
-V8GenerateIsReachable=ImplDocument|ImplElementRoot|ImplOwnerRoot|ImplOwnerNodeRoot
-V8NoWrapperCache
-V8MeasureAs=*
-V8ReadOnly
-V8Unforgeable
diff --git a/contrib/dom/scripts/IDLParser.pm b/contrib/dom/scripts/IDLParser.pm
deleted file mode 100644
index 61fab7b..0000000
--- a/contrib/dom/scripts/IDLParser.pm
+++ /dev/null
@@ -1,2456 +0,0 @@
-#
-# KDOM IDL parser
-#
-# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
-#
-# 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.
-#
-
-package IDLParser;
-
-use strict;
-
-use preprocessor;
-use Class::Struct;
-use Data::Dumper;
-
-use constant StringToken => 0;
-use constant IntegerToken => 1;
-use constant FloatToken => 2;
-use constant IdentifierToken => 3;
-use constant OtherToken => 4;
-use constant EmptyToken => 5;
-
-# Used to represent a parsed IDL document
-struct( idlDocument => {
- interfaces => '@', # All parsed interfaces
- fileName => '$' # file name
-});
-
-# Used to represent 'interface' blocks
-struct( domInterface => {
- name => '$', # Class identifier
- parents => '@', # List of strings
- constants => '@', # List of 'domConstant'
- functions => '@', # List of 'domFunction'
- attributes => '@', # List of 'domAttribute'
- extendedAttributes => '$', # Extended attributes
- constructors => '@', # Constructor
- isException => '$', # Used for exception interfaces
-});
-
-# Used to represent domInterface contents (name of method, signature)
-struct( domFunction => {
- isStatic => '$',
- signature => '$', # Return type/Object name/extended attributes
- parameters => '@', # List of 'domSignature'
- raisesExceptions => '@', # Possibly raised exceptions.
-});
-
-# Used to represent domInterface contents (name of attribute, signature)
-struct( domAttribute => {
- type => '$', # Attribute type (including namespace)
- isStatic => '$',
- signature => '$', # Attribute signature
- getterExceptions => '@', # Possibly raised exceptions.
- setterExceptions => '@', # Possibly raised exceptions.
-});
-
-# Used to represent a map of 'variable name' <-> 'variable type'
-struct( domSignature => {
- direction => '$', # Variable direction (in or out)
- name => '$', # Variable name
- type => '$', # Variable type
- extendedAttributes => '$', # Extended attributes
- isNullable => '$', # Is variable type Nullable (T?)
- isOptional => '$', # Is variable optional (T?)
- isVariadic => '$' # Is variable variadic (long... numbers)
-});
-
-# Used to represent string constants
-struct( domConstant => {
- name => '$', # DOM Constant identifier
- type => '$', # Type of data
- value => '$', # Constant value
- extendedAttributes => '$', # Extended attributes
-});
-
-struct( Token => {
- type => '$', # type of token
- value => '$' # value of token
-});
-
-sub new {
- my $class = shift;
-
- my $emptyToken = Token->new();
- $emptyToken->type(EmptyToken);
- $emptyToken->value("empty");
-
- my $self = {
- DocumentContent => "",
- EmptyToken => $emptyToken,
- NextToken => $emptyToken,
- Token => $emptyToken,
- Line => "",
- LineNumber => 1
- };
- return bless $self, $class;
-}
-
-sub assertTokenValue
-{
- my $self = shift;
- my $token = shift;
- my $value = shift;
- my $line = shift;
- my $msg = "Next token should be " . $value . ", but " . $token->value() . " at " . $self->{Line};
- if (defined ($line)) {
- $msg .= " IDLParser.pm:" . $line;
- }
- die $msg unless $token->value() eq $value;
-}
-
-sub assertTokenType
-{
- my $self = shift;
- my $token = shift;
- my $type = shift;
- die "Next token's type should be " . $type . ", but " . $token->type() . " at " . $self->{Line} unless $token->type() eq $type;
-}
-
-sub assertUnexpectedToken
-{
- my $self = shift;
- my $token = shift;
- my $line = shift;
- my $msg = "Unexpected token " . $token . " at " . $self->{Line};
- if (defined ($line)) {
- $msg .= " IDLParser.pm:" . $line;
- }
- die $msg;
-}
-
-sub Parse
-{
- my $self = shift;
- my $fileName = shift;
- my $defines = shift;
- my $preprocessor = shift;
-
- my @definitions = ();
-
- my @lines = applyPreprocessor($fileName, $defines, $preprocessor);
- $self->{Line} = $lines[0];
- $self->{DocumentContent} = join(' ', @lines);
-
- $self->getToken();
- eval {
- my $result = $self->parseDefinitions();
- push(@definitions, @{$result});
-
- my $next = $self->nextToken();
- $self->assertTokenType($next, EmptyToken);
- };
- die $@ . " in $fileName" if $@;
-
- die "No document found" unless @definitions;
-
- my $document;
- if ($#definitions == 0 && ref($definitions[0]) eq "idlDocument") {
- $document = $definitions[0];
- } else {
- $document = idlDocument->new();
- push(@{$document->interfaces}, @definitions);
- }
-
- $document->fileName($fileName);
- return $document;
-}
-
-sub nextToken
-{
- my $self = shift;
- return $self->{NextToken};
-}
-
-sub getToken
-{
- my $self = shift;
- $self->{Token} = $self->{NextToken};
- $self->{NextToken} = $self->getTokenInternal();
- return $self->{Token};
-}
-
-my $whitespaceTokenPattern = '^[\t\n\r ]*[\n\r]';
-my $floatTokenPattern = '^(-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+))';
-my $integerTokenPattern = '^(-?[1-9][0-9]*|-?0[Xx][0-9A-Fa-f]+|-?0[0-7]*)';
-my $stringTokenPattern = '^(\"[^\"]*\")';
-my $identifierTokenPattern = '^([A-Z_a-z][0-9A-Z_a-z]*)';
-my $otherTokenPattern = '^(::|\.\.\.|[^\t\n\r 0-9A-Z_a-z])';
-
-sub getTokenInternal
-{
- my $self = shift;
-
- if ($self->{DocumentContent} =~ /$whitespaceTokenPattern/) {
- $self->{DocumentContent} =~ s/($whitespaceTokenPattern)//;
- my $skipped = $1;
- $self->{LineNumber}++ while ($skipped =~ /\n/g);
- if ($self->{DocumentContent} =~ /^([^\n\r]+)/) {
- $self->{Line} = $self->{LineNumber} . ":" . $1;
- } else {
- $self->{Line} = "Unknown";
- }
- }
- $self->{DocumentContent} =~ s/^([\t\n\r ]+)//;
- if ($self->{DocumentContent} eq "") {
- return $self->{EmptyToken};
- }
-
- my $token = Token->new();
- if ($self->{DocumentContent} =~ /$floatTokenPattern/) {
- $token->type(FloatToken);
- $token->value($1);
- $self->{DocumentContent} =~ s/$floatTokenPattern//;
- return $token;
- }
- if ($self->{DocumentContent} =~ /$integerTokenPattern/) {
- $token->type(IntegerToken);
- $token->value($1);
- $self->{DocumentContent} =~ s/$integerTokenPattern//;
- return $token;
- }
- if ($self->{DocumentContent} =~ /$stringTokenPattern/) {
- $token->type(StringToken);
- $token->value($1);
- $self->{DocumentContent} =~ s/$stringTokenPattern//;
- return $token;
- }
- if ($self->{DocumentContent} =~ /$identifierTokenPattern/) {
- $token->type(IdentifierToken);
- $token->value($1);
- $self->{DocumentContent} =~ s/$identifierTokenPattern//;
- return $token;
- }
- if ($self->{DocumentContent} =~ /$otherTokenPattern/) {
- $token->type(OtherToken);
- $token->value($1);
- $self->{DocumentContent} =~ s/$otherTokenPattern//;
- return $token;
- }
- die "Failed in tokenizing at " . $self->{Line};
-}
-
-my $nextAttributeOld_1 = '^(attribute|inherit|readonly)$';
-my $nextPrimitiveType_1 = '^(int|long|short|unsigned)$';
-my $nextPrimitiveType_2 = '^(double|float|unrestricted)$';
-my $nextSetGetRaises2_1 = '^(;|getraises|setraises)$';
-my $nextArgumentList_1 = '^(\(|::|ByteString|DOMString|Date|\[|any|boolean|byte|double|float|in|int|long|object|octet|optional|sequence|short|unrestricted|unsigned)$';
-my $nextNonAnyType_1 = '^(boolean|byte|double|float|int|long|octet|short|unrestricted|unsigned)$';
-my $nextInterfaceMemberOld_1 = '^(\(|::|ByteString|DOMString|Date|any|attribute|boolean|byte|creator|deleter|double|float|getter|inherit|int|legacycaller|long|object|octet|readonly|sequence|serializer|setter|short|static|stringifier|unrestricted|unsigned|void)$';
-my $nextOptionalIteratorInterfaceOrObject_1 = '^(;|=)$';
-my $nextAttributeOrOperationOrIterator_1 = '^(static|stringifier)$';
-my $nextAttributeOrOperationOrIterator_2 = '^(\(|::|ByteString|DOMString|Date|any|boolean|byte|creator|deleter|double|float|getter|int|legacycaller|long|object|octet|sequence|setter|short|unrestricted|unsigned|void)$';
-my $nextUnrestrictedFloatType_1 = '^(double|float)$';
-my $nextExtendedAttributeRest3_1 = '^(\,|::|\])$';
-my $nextExceptionField_1 = '^(\(|::|ByteString|DOMString|Date|any|boolean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$';
-my $nextType_1 = '^(::|ByteString|DOMString|Date|any|boolean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$';
-my $nextSpecials_1 = '^(creator|deleter|getter|legacycaller|setter)$';
-my $nextDefinitions_1 = '^(::|callback|dictionary|enum|exception|interface|partial|typedef)$';
-my $nextExceptionMembers_1 = '^(\(|::|ByteString|DOMString|Date|\[|any|boolean|byte|const|double|float|int|long|object|octet|optional|sequence|short|unrestricted|unsigned)$';
-my $nextAttributeRest_1 = '^(attribute|readonly)$';
-my $nextInterfaceMembers_1 = '^(\(|::|ByteString|DOMString|Date|any|attribute|boolean|byte|const|creator|deleter|double|float|getter|inherit|int|legacycaller|long|object|octet|readonly|sequence|serializer|setter|short|static|stringifier|unrestricted|unsigned|void)$';
-my $nextSingleType_1 = '^(::|ByteString|DOMString|Date|boolean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned)$';
-my $nextGet_1 = '^(;|getraises|getter|setraises|setter)$';
-my $nextArgumentName_1 = '^(attribute|callback|const|creator|deleter|dictionary|enum|exception|getter|implements|inherit|interface|legacycaller|partial|serializer|setter|static|stringifier|typedef|unrestricted)$';
-my $nextConstValue_1 = '^(false|true)$';
-my $nextConstValue_2 = '^(-|Infinity|NaN)$';
-my $nextDefinition_1 = '^(callback|interface)$';
-my $nextAttributeOrOperationRest_1 = '^(\(|::|ByteString|DOMString|Date|any|boolean|byte|double|float|int|long|object|octet|sequence|short|unrestricted|unsigned|void)$';
-my $nextUnsignedIntegerType_1 = '^(int|long|short)$';
-my $nextDefaultValue_1 = '^(-|Infinity|NaN|false|null|true)$';
-
-
-sub parseDefinitions
-{
- my $self = shift;
- my @definitions = ();
-
- while (1) {
- my $next = $self->nextToken();
- my $definition;
- if ($next->value() eq "[") {
- my $extendedAttributeList = $self->parseExtendedAttributeList();
- $definition = $self->parseDefinition($extendedAttributeList);
- } elsif ($next->type() == IdentifierToken || $next->value() =~ /$nextDefinitions_1/) {
- $definition = $self->parseDefinitionOld();
- } else {
- last;
- }
- if (defined ($definition)) {
- push(@definitions, $definition);
- }
- }
- return \@definitions;
-}
-
-sub parseDefinition
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextDefinition_1/) {
- return $self->parseCallbackOrInterface($extendedAttributeList);
- }
- if ($next->value() eq "partial") {
- return $self->parsePartial($extendedAttributeList);
- }
- if ($next->value() eq "dictionary") {
- return $self->parseDictionary($extendedAttributeList);
- }
- if ($next->value() eq "exception") {
- return $self->parseException($extendedAttributeList);
- }
- if ($next->value() eq "enum") {
- return $self->parseEnum($extendedAttributeList);
- }
- if ($next->value() eq "typedef") {
- return $self->parseTypedef($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- return $self->parseImplementsStatement($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseCallbackOrInterface
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "callback") {
- $self->assertTokenValue($self->getToken(), "callback", __LINE__);
- return $self->parseCallbackRestOrInterface($extendedAttributeList);
- }
- if ($next->value() eq "interface") {
- return $self->parseInterface($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseCallbackRestOrInterface
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "interface") {
- return $self->parseInterface($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken) {
- return $self->parseCallbackRest($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseInterface
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "interface") {
- my $interface = domInterface->new();
- $self->assertTokenValue($self->getToken(), "interface", __LINE__);
- my $interfaceNameToken = $self->getToken();
- $self->assertTokenType($interfaceNameToken, IdentifierToken);
- $interface->name($interfaceNameToken->value());
- push(@{$interface->parents}, @{$self->parseInheritance()});
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- my $interfaceMembers = $self->parseInterfaceMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- applyMemberList($interface, $interfaceMembers);
- applyExtendedAttributeList($interface, $extendedAttributeList);
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parsePartial
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "partial") {
- $self->assertTokenValue($self->getToken(), "partial", __LINE__);
- return $self->parsePartialDefinition($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parsePartialDefinition
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "interface") {
- return $self->parsePartialInterface($extendedAttributeList);
- }
- if ($next->value() eq "dictionary") {
- return $self->parsePartialDictionary($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parsePartialInterface
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "interface") {
- $self->assertTokenValue($self->getToken(), "interface", __LINE__);
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseInterfaceMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseInterfaceMembers
-{
- my $self = shift;
- my @interfaceMembers = ();
-
- while (1) {
- my $next = $self->nextToken();
- my $interfaceMember;
-
- if ($next->value() eq "[") {
- my $extendedAttributeList = $self->parseExtendedAttributeList();
- $interfaceMember = $self->parseInterfaceMember($extendedAttributeList);
- } elsif ($next->type() == IdentifierToken || $next->value() =~ /$nextInterfaceMembers_1/) {
- $interfaceMember = $self->parseInterfaceMemberOld();
- } else {
- last;
- }
- if (defined $interfaceMember) {
- push(@interfaceMembers, $interfaceMember);
- }
- }
- return \@interfaceMembers;
-}
-
-sub parseInterfaceMember
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "const") {
- return $self->parseConst($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextInterfaceMemberOld_1/) {
- return $self->parseAttributeOrOperationOrIterator($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseDictionary
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "dictionary") {
- $self->assertTokenValue($self->getToken(), "dictionary", __LINE__);
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseInheritance();
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseDictionaryMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseDictionaryMembers
-{
- my $self = shift;
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq "[") {
- my $extendedAttributeList = $self->parseExtendedAttributeList();
- $self->parseDictionaryMember($extendedAttributeList);
- } elsif ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- $self->parseDictionaryMemberOld();
- } else {
- last;
- }
- }
-}
-
-sub parseDictionaryMember
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- $self->parseType();
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseDefault();
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parsePartialDictionary
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "dictionary") {
- $self->assertTokenValue($self->getToken(), "dictionary", __LINE__);
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseDictionaryMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseDefault
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "=") {
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- return $self->parseDefaultValue();
- }
-}
-
-sub parseDefaultValue
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == FloatToken || $next->type() == IntegerToken || $next->value() =~ /$nextDefaultValue_1/) {
- return $self->parseConstValue();
- }
- if ($next->type() == StringToken) {
- return $self->getToken()->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseException
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "exception") {
- my $interface = domInterface->new();
- $self->assertTokenValue($self->getToken(), "exception", __LINE__);
- my $exceptionNameToken = $self->getToken();
- $self->assertTokenType($exceptionNameToken, IdentifierToken);
- $interface->name($exceptionNameToken->value());
- $interface->isException(1);
- push(@{$interface->parents}, @{$self->parseInheritance()});
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- my $exceptionMembers = $self->parseExceptionMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- applyMemberList($interface, $exceptionMembers);
- applyExtendedAttributeList($interface, $extendedAttributeList);
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExceptionMembers
-{
- my $self = shift;
- my @members = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionMembers_1/) {
- my $extendedAttributeList = $self->parseExtendedAttributeListAllowEmpty();
- #my $member = $self->parseExceptionMember($extendedAttributeList);
- my $member = $self->parseInterfaceMember($extendedAttributeList);
- if (defined ($member)) {
- push(@members, $member);
- }
- } else {
- last;
- }
- }
- return \@members;
-}
-
-sub parseInheritance
-{
- my $self = shift;
- my @parent = ();
-
- my $next = $self->nextToken();
- if ($next->value() eq ":") {
- $self->assertTokenValue($self->getToken(), ":", __LINE__);
- my $scopedName = $self->parseScopedName();
- push(@parent, $scopedName);
- # Multiple inheritance?
- push(@parent, @{$self->parseIdentifiers()});
- }
- return \@parent;
-}
-
-sub parseEnum
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "enum") {
- $self->assertTokenValue($self->getToken(), "enum", __LINE__);
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseEnumValueList();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseEnumValueList
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == StringToken) {
- $self->assertTokenType($self->getToken(), StringToken);
- $self->parseEnumValues();
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseEnumValues
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",", __LINE__);
- $self->assertTokenType($self->getToken(), StringToken);
- $self->parseEnumValues();
- }
-}
-
-sub parseCallbackRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken) {
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- $self->parseReturnType();
- $self->assertTokenValue($self->getToken(), "(", __LINE__);
- $self->parseArgumentList();
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseTypedef
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "typedef") {
- $self->assertTokenValue($self->getToken(), "typedef", __LINE__);
- $self->parseExtendedAttributeList();
- $self->parseType();
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseImplementsStatement
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken) {
- $self->parseScopedName();
- $self->assertTokenValue($self->getToken(), "implements", __LINE__);
- $self->parseScopedName();
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseConst
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "const") {
- my $newDataNode = domConstant->new();
- $self->assertTokenValue($self->getToken(), "const", __LINE__);
- $newDataNode->type($self->parseConstType());
- my $constNameToken = $self->getToken();
- $self->assertTokenType($constNameToken, IdentifierToken);
- $newDataNode->name($constNameToken->value());
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- $newDataNode->value($self->parseConstValue());
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- $newDataNode->extendedAttributes($extendedAttributeList);
- return $newDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseConstValue
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextConstValue_1/) {
- return $self->parseBooleanLiteral();
- }
- if ($next->value() eq "null") {
- $self->assertTokenValue($self->getToken(), "null", __LINE__);
- return "null";
- }
- if ($next->type() == FloatToken || $next->value() =~ /$nextConstValue_2/) {
- return $self->parseFloatLiteral();
- }
- # backward compatibility
- if ($next->type() == StringToken) {
- return $self->getToken()->value();
- }
- if ($next->type() == IntegerToken) {
- return $self->getToken()->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseBooleanLiteral
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "true") {
- $self->assertTokenValue($self->getToken(), "true", __LINE__);
- return "true";
- }
- if ($next->value() eq "false") {
- $self->assertTokenValue($self->getToken(), "false", __LINE__);
- return "false";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseFloatLiteral
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "-") {
- $self->assertTokenValue($self->getToken(), "-", __LINE__);
- $self->assertTokenValue($self->getToken(), "Infinity", __LINE__);
- return "-Infinity";
- }
- if ($next->value() eq "Infinity") {
- $self->assertTokenValue($self->getToken(), "Infinity", __LINE__);
- return "Infinity";
- }
- if ($next->value() eq "NaN") {
- $self->assertTokenValue($self->getToken(), "NaN", __LINE__);
- return "NaN";
- }
- if ($next->type() == FloatToken) {
- return $self->getToken()->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeOrOperationOrIterator
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "serializer") {
- return $self->parseSerializer($extendedAttributeList);
- }
- if ($next->value() =~ /$nextAttributeOrOperationOrIterator_1/) {
- my $qualifier = $self->parseQualifier();
- my $newDataNode = $self->parseAttributeOrOperationRest($extendedAttributeList);
- if (defined($newDataNode) && $qualifier eq "static") {
- $newDataNode->isStatic(1);
- }
- return $newDataNode;
- }
- if ($next->value() =~ /$nextAttributeOld_1/) {
- return $self->parseAttribute($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationOrIterator_2/) {
- return $self->parseOperationOrIterator($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSerializer
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "serializer") {
- $self->assertTokenValue($self->getToken(), "serializer", __LINE__);
- return $self->parseSerializerRest($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSerializerRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "=") {
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- return $self->parseSerializationPattern($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() eq "(") {
- return $self->parseOperationRest($extendedAttributeList);
- }
-}
-
-sub parseSerializationPattern
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "{") {
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseSerializationPatternMap();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- return;
- }
- if ($next->value() eq "[") {
- $self->assertTokenValue($self->getToken(), "[", __LINE__);
- $self->parseSerializationPatternList();
- $self->assertTokenValue($self->getToken(), "]", __LINE__);
- return;
- }
- if ($next->type() == IdentifierToken) {
- $self->assertTokenType($self->getToken(), IdentifierToken);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSerializationPatternMap
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "getter") {
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- return;
- }
- if ($next->value() eq "inherit") {
- $self->assertTokenValue($self->getToken(), "inherit", __LINE__);
- $self->parseIdentifiers();
- return;
- }
- if ($next->type() == IdentifierToken) {
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseIdentifiers();
- }
-}
-
-sub parseSerializationPatternList
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "getter") {
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- return;
- }
- if ($next->type() == IdentifierToken) {
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseIdentifiers();
- }
-}
-
-sub parseIdentifiers
-{
- my $self = shift;
- my @idents = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",", __LINE__);
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- push(@idents, $token->value());
- } else {
- last;
- }
- }
- return \@idents;
-}
-
-sub parseQualifier
-{
- my $self = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "static") {
- $self->assertTokenValue($self->getToken(), "static", __LINE__);
- return "static";
- }
- if ($next->value() eq "stringifier") {
- $self->assertTokenValue($self->getToken(), "stringifier", __LINE__);
- return "stringifier";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeOrOperationRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeRest_1/) {
- return $self->parseAttributeRest($extendedAttributeList);
- }
- if ($next->value() eq ";") {
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationRest_1/) {
- my $returnType = $self->parseReturnType();
- my $interface = $self->parseOperationRest($extendedAttributeList);
- if (defined ($interface)) {
- $interface->signature->type($returnType);
- }
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttribute
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeOld_1/) {
- $self->parseInherit();
- return $self->parseAttributeRest($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeRest_1/) {
- my $newDataNode = domAttribute->new();
- if ($self->parseReadOnly()) {
- $newDataNode->type("readonly attribute");
- } else {
- $newDataNode->type("attribute");
- }
- $self->assertTokenValue($self->getToken(), "attribute", __LINE__);
- $newDataNode->signature(domSignature->new());
- $newDataNode->signature->type($self->parseType());
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- $newDataNode->signature->name($token->value());
- my $getRef = $self->parseGet();
- if (defined $getRef) {
- push(@{$newDataNode->getterExceptions}, @{$getRef->{"getraises"}});
- push(@{$newDataNode->setterExceptions}, @{$getRef->{"setraises"}});
- }
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- $newDataNode->signature->extendedAttributes($extendedAttributeList);
- return $newDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseInherit
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "inherit") {
- $self->assertTokenValue($self->getToken(), "inherit", __LINE__);
- return 1;
- }
- return 0;
-}
-
-sub parseReadOnly
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "readonly") {
- $self->assertTokenValue($self->getToken(), "readonly", __LINE__);
- return 1;
- }
- return 0;
-}
-
-sub parseOperationOrIterator
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextSpecials_1/) {
- return $self->parseSpecialOperation($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationRest_1/) {
- my $returnType = $self->parseReturnType();
- my $interface = $self->parseOperationOrIteratorRest($extendedAttributeList);
- if (defined ($interface)) {
- $interface->signature->type($returnType);
- }
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSpecialOperation
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextSpecials_1/) {
- $self->parseSpecial();
- $self->parseSpecials();
- my $returnType = $self->parseReturnType();
- my $interface = $self->parseOperationRest($extendedAttributeList);
- if (defined ($interface)) {
- $interface->signature->type($returnType);
- }
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSpecials
-{
- my $self = shift;
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextSpecials_1/) {
- $self->parseSpecial();
- } else {
- last;
- }
- }
- return [];
-}
-
-sub parseSpecial
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "getter") {
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- return "getter";
- }
- if ($next->value() eq "setter") {
- $self->assertTokenValue($self->getToken(), "setter", __LINE__);
- return "setter";
- }
- if ($next->value() eq "creator") {
- $self->assertTokenValue($self->getToken(), "creator", __LINE__);
- return "creator";
- }
- if ($next->value() eq "deleter") {
- $self->assertTokenValue($self->getToken(), "deleter", __LINE__);
- return "deleter";
- }
- if ($next->value() eq "legacycaller") {
- $self->assertTokenValue($self->getToken(), "legacycaller", __LINE__);
- return "legacycaller";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOperationOrIteratorRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "iterator") {
- return $self->parseIteratorRest($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() eq "(") {
- return $self->parseOperationRest($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseIteratorRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "iterator") {
- $self->assertTokenValue($self->getToken(), "iterator", __LINE__);
- $self->parseOptionalIteratorInterfaceOrObject($extendedAttributeList);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOptionalIteratorInterfaceOrObject
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextOptionalIteratorInterfaceOrObject_1/) {
- return $self->parseOptionalIteratorInterface($extendedAttributeList);
- }
- if ($next->value() eq "object") {
- $self->assertTokenValue($self->getToken(), "object", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOptionalIteratorInterface
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "=") {
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- $self->assertTokenType($self->getToken(), IdentifierToken);
- }
-}
-
-sub parseOperationRest
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "(") {
- my $newDataNode = domFunction->new();
- $newDataNode->signature(domSignature->new());
- my $name = $self->parseOptionalIdentifier();
- $newDataNode->signature->name($name);
- $self->assertTokenValue($self->getToken(), "(", $name, __LINE__);
- push(@{$newDataNode->parameters}, @{$self->parseArgumentList()});
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- push(@{$newDataNode->raisesExceptions}, @{$self->parseRaises()});
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- $newDataNode->signature->extendedAttributes($extendedAttributeList);
- return $newDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOptionalIdentifier
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken) {
- my $token = $self->getToken();
- return $token->value();
- }
- return "";
-}
-
-sub parseArgumentList
-{
- my $self = shift;
- my @arguments = ();
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextArgumentList_1/) {
- push(@arguments, $self->parseArgument());
- push(@arguments, @{$self->parseArguments()});
- }
- return \@arguments;
-}
-
-sub parseArguments
-{
- my $self = shift;
- my @arguments = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",", __LINE__);
- push(@arguments, $self->parseArgument());
- } else {
- last;
- }
- }
- return \@arguments;
-}
-
-sub parseArgument
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextArgumentList_1/) {
- my $in = $self->parseIn();
- my $extendedAttributeList = $self->parseExtendedAttributeListAllowEmpty();
- my $argument = $self->parseOptionalOrRequiredArgument($extendedAttributeList);
- $argument->direction($self->parseIn());
- return $argument;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOptionalOrRequiredArgument
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $paramDataNode = domSignature->new();
- $paramDataNode->extendedAttributes($extendedAttributeList);
-
- my $next = $self->nextToken();
- if ($next->value() eq "optional") {
- $self->assertTokenValue($self->getToken(), "optional", __LINE__);
- my $type = $self->parseType();
- # domDataNode can only consider last "?".
- if ($type =~ /\?$/) {
- $paramDataNode->isNullable(1);
- } else {
- $paramDataNode->isNullable(0);
- }
- # Remove all "?" if exists, e.g. "object?[]?" -> "object[]".
- $type =~ s/\?//g;
- $paramDataNode->type($type);
- $paramDataNode->name($self->parseArgumentName());
- $self->parseDefault();
- $paramDataNode->isOptional(1);
-# print Dumper($paramDataNode);
- return $paramDataNode;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- my $type = $self->parseType();
- # domDataNode can only consider last "?".
- if ($type =~ /\?$/) {
- $paramDataNode->isNullable(1);
- } else {
- $paramDataNode->isNullable(0);
- }
- # Remove all "?" if exists, e.g. "object?[]?" -> "object[]".
- $type =~ s/\?//g;
- $paramDataNode->type($type);
- $paramDataNode->isVariadic($self->parseEllipsis());
- $paramDataNode->name($self->parseArgumentName());
- return $paramDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseArgumentName
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextArgumentName_1/) {
- return $self->parseArgumentNameKeyword();
- }
- if ($next->type() == IdentifierToken) {
- return $self->getToken()->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseEllipsis
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "...") {
- $self->assertTokenValue($self->getToken(), "...", __LINE__);
- return 1;
- }
- return 0;
-}
-
-sub parseExceptionMember
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "const") {
- return $self->parseConst($extendedAttributeList);
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- return $self->parseExceptionField($extendedAttributeList);
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExceptionField
-{
- my $self = shift;
- my $extendedAttributeList = shift;
-
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- my $newDataNode = domAttribute->new();
- $newDataNode->type("readonly attribute");
- $newDataNode->signature(domSignature->new());
- $newDataNode->signature->type($self->parseType());
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- $newDataNode->signature->name($token->value());
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- $newDataNode->signature->extendedAttributes($extendedAttributeList);
- return $newDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExtendedAttributeListAllowEmpty
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "[") {
- return $self->parseExtendedAttributeList();
- }
- return {};
-}
-
-sub copyExtendedAttributes
-{
- my $extendedAttributeList = shift;
- my $attr = shift;
-
- for my $key (keys %{$attr}) {
- if ($key eq "Constructor") {
- push(@{$extendedAttributeList->{"Constructors"}}, $attr->{$key});
- } elsif ($key eq "Constructors") {
- my @constructors = @{$attr->{$key}};
- foreach my $constructor (@constructors) {
- push(@{$extendedAttributeList->{"Constructors"}}, $constructor);
- }
- } else {
- $extendedAttributeList->{$key} = $attr->{$key};
- }
- }
-}
-
-sub parseExtendedAttributeList
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "[") {
- $self->assertTokenValue($self->getToken(), "[", __LINE__);
- my $extendedAttributeList = {};
- my $attr = $self->parseExtendedAttribute();
- copyExtendedAttributes($extendedAttributeList, $attr);
- $attr = $self->parseExtendedAttributes();
- copyExtendedAttributes($extendedAttributeList, $attr);
- $self->assertTokenValue($self->getToken(), "]", __LINE__);
- return $extendedAttributeList;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExtendedAttributes
-{
- my $self = shift;
- my $extendedAttributeList = {};
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",", __LINE__);
- my $attr = $self->parseExtendedAttribute2();
- copyExtendedAttributes($extendedAttributeList, $attr);
- } else {
- last;
- }
- }
- return $extendedAttributeList;
-}
-
-sub parseExtendedAttribute
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- my $scopedName = $self->parseScopedName();
- return $self->parseExtendedAttributeRest($scopedName);
- }
- # backward compatibility. Spec doesn' allow "[]". But WebKit requires.
- if ($next->value() eq ']') {
- return {};
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExtendedAttribute2
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- my $scopedName = $self->parseScopedName();
- return $self->parseExtendedAttributeRest($scopedName);
- }
- return {};
-}
-
-sub parseExtendedAttributeRest
-{
- my $self = shift;
- my $name = shift;
- my $attrs = {};
-
- my $next = $self->nextToken();
- if ($next->value() eq "(") {
- $self->assertTokenValue($self->getToken(), "(", __LINE__);
- $attrs->{$name} = $self->parseArgumentList();
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- return $attrs;
- }
- if ($next->value() eq "=") {
- $self->assertTokenValue($self->getToken(), "=", __LINE__);
- $attrs->{$name} = $self->parseExtendedAttributeRest2();
- return $attrs;
- }
-
- if ($name eq "Constructor") {
- $attrs->{$name} = [];
- } else {
- $attrs->{$name} = "VALUE_IS_MISSING";
- }
- return $attrs;
-}
-
-sub parseExtendedAttributeRest2
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- my $scopedName = $self->parseScopedName();
- return $self->parseExtendedAttributeRest3($scopedName);
- }
- if ($next->type() == IntegerToken) {
- my $token = $self->getToken();
- return $token->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExtendedAttributeRest3
-{
- my $self = shift;
- my $name = shift;
-
- my $next = $self->nextToken();
- if ($next->value() eq "&") {
- $self->assertTokenValue($self->getToken(), "&", __LINE__);
- my $rightValue = $self->parseScopedName();
- return $name . "&" . $rightValue;
- }
- if ($next->value() eq "|") {
- $self->assertTokenValue($self->getToken(), "|", __LINE__);
- my $rightValue = $self->parseScopedName();
- return $name . "|" . $rightValue;
- }
- if ($next->value() eq "(") {
- my $attr = {};
- $self->assertTokenValue($self->getToken(), "(", __LINE__);
- $attr->{$name} = $self->parseArgumentList();
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- return $attr;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExtendedAttributeRest3_1/) {
- my @names = ();
- push(@names, $name);
- push(@names, @{$self->parseScopedNameListNoComma()});
- return join(' ', @names);
- }
- $self->assertUnexpectedToken($next->value());
-}
-
-sub parseScopedNameListNoComma
-{
- my $self = shift;
- my @names = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- push(@names, $self->parseScopedName());
- } else {
- last;
- }
- }
- return \@names;
-}
-
-sub parseArgumentNameKeyword
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "attribute") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "callback") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "const") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "creator") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "deleter") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "dictionary") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "enum") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "exception") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "getter") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "implements") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "inherit") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "interface") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "legacycaller") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "partial") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "serializer") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "setter") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "static") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "stringifier") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "typedef") {
- return $self->getToken()->value();
- }
- if ($next->value() eq "unrestricted") {
- return $self->getToken()->value();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "(") {
- $self->parseUnionType();
- $self->parseTypeSuffix();
- return;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextType_1/) {
- return $self->parseSingleType();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSingleType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "any") {
- $self->assertTokenValue($self->getToken(), "any", __LINE__);
- return "any" . $self->parseTypeSuffixStartingWithArray();
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextSingleType_1/) {
- return $self->parseNonAnyType();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseUnionType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "(") {
- $self->assertTokenValue($self->getToken(), "(", __LINE__);
- $self->parseUnionMemberType();
- $self->assertTokenValue($self->getToken(), "or", __LINE__);
- $self->parseUnionMemberType();
- $self->parseUnionMemberTypes();
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseUnionMemberType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "(") {
- $self->parseUnionType();
- $self->parseTypeSuffix();
- return;
- }
- if ($next->value() eq "any") {
- $self->assertTokenValue($self->getToken(), "any", __LINE__);
- $self->assertTokenValue($self->getToken(), "[", __LINE__);
- $self->assertTokenValue($self->getToken(), "]", __LINE__);
- $self->parseTypeSuffix();
- return;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextSingleType_1/) {
- $self->parseNonAnyType();
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseUnionMemberTypes
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "or") {
- $self->assertTokenValue($self->getToken(), "or", __LINE__);
- $self->parseUnionMemberType();
- $self->parseUnionMemberTypes();
- }
-}
-
-sub parseNonAnyType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextNonAnyType_1/) {
- return $self->parsePrimitiveType() . $self->parseTypeSuffix();
- }
- if ($next->value() eq "ByteString") {
- $self->assertTokenValue($self->getToken(), "ByteString", __LINE__);
- return "ByteString" . $self->parseTypeSuffix();
- }
- if ($next->value() eq "DOMString") {
- $self->assertTokenValue($self->getToken(), "DOMString", __LINE__);
- return "DOMString" . $self->parseTypeSuffix();
- }
- if ($next->value() eq "sequence") {
- $self->assertTokenValue($self->getToken(), "sequence", __LINE__);
- $self->assertTokenValue($self->getToken(), "<", __LINE__);
- my $type = $self->parseType();
- $self->assertTokenValue($self->getToken(), ">", __LINE__);
- return "sequence<" . $type . ">" . $self->parseNull();
- }
- if ($next->value() eq "object") {
- $self->assertTokenValue($self->getToken(), "object", __LINE__);
- return "object" . $self->parseTypeSuffix();
- }
- if ($next->value() eq "Date") {
- $self->assertTokenValue($self->getToken(), "Date", __LINE__);
- return "Date" . $self->parseTypeSuffix();
- }
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- my $name = $self->parseScopedName();
- return $name . $self->parseTypeSuffix();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseConstType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextNonAnyType_1/) {
- return $self->parsePrimitiveType() . $self->parseNull();
- }
- if ($next->type() == IdentifierToken) {
- my $token = $self->getToken();
- return $token->value() . $self->parseNull();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parsePrimitiveType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextPrimitiveType_1/) {
- return $self->parseUnsignedIntegerType();
- }
- if ($next->value() =~ /$nextPrimitiveType_2/) {
- return $self->parseUnrestrictedFloatType();
- }
- if ($next->value() eq "boolean") {
- $self->assertTokenValue($self->getToken(), "boolean", __LINE__);
- return "boolean";
- }
- if ($next->value() eq "byte") {
- $self->assertTokenValue($self->getToken(), "byte", __LINE__);
- return "byte";
- }
- if ($next->value() eq "octet") {
- $self->assertTokenValue($self->getToken(), "octet", __LINE__);
- return "octet";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseUnrestrictedFloatType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "unrestricted") {
- $self->assertTokenValue($self->getToken(), "unrestricted", __LINE__);
- return "unrestricted" . $self->parseFloatType();
- }
- if ($next->value() =~ /$nextUnrestrictedFloatType_1/) {
- return $self->parseFloatType();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseFloatType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "float") {
- $self->assertTokenValue($self->getToken(), "float", __LINE__);
- return "float";
- }
- if ($next->value() eq "double") {
- $self->assertTokenValue($self->getToken(), "double", __LINE__);
- return "double";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseUnsignedIntegerType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "unsigned") {
- $self->assertTokenValue($self->getToken(), "unsigned", __LINE__);
- return "unsigned " . $self->parseIntegerType();
- }
- if ($next->value() =~ /$nextUnsignedIntegerType_1/) {
- return $self->parseIntegerType();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseIntegerType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "short") {
- $self->assertTokenValue($self->getToken(), "short", __LINE__);
- return "short";
- }
- if ($next->value() eq "int") {
- $self->assertTokenValue($self->getToken(), "int", __LINE__);
- return "int";
- }
- if ($next->value() eq "long") {
- $self->assertTokenValue($self->getToken(), "long", __LINE__);
- if ($self->parseOptionalLong()) {
- return "long long";
- }
- return "long";
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseOptionalLong
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "long") {
- $self->assertTokenValue($self->getToken(), "long", __LINE__);
- return 1;
- }
- return 0;
-}
-
-sub parseTypeSuffix
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "[") {
- $self->assertTokenValue($self->getToken(), "[", __LINE__);
- $self->assertTokenValue($self->getToken(), "]", __LINE__);
- return "[]" . $self->parseTypeSuffix();
- }
- if ($next->value() eq "?") {
- $self->assertTokenValue($self->getToken(), "?", __LINE__);
- return "?" . $self->parseTypeSuffixStartingWithArray();
- }
- return "";
-}
-
-sub parseTypeSuffixStartingWithArray
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "[") {
- $self->assertTokenValue($self->getToken(), "[", __LINE__);
- $self->assertTokenValue($self->getToken(), "]", __LINE__);
- return "[]" . $self->parseTypeSuffix();
- }
- return "";
-}
-
-sub parseNull
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "?") {
- $self->assertTokenValue($self->getToken(), "?", __LINE__);
- return "?";
- }
- return "";
-}
-
-sub parseReturnType
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "void") {
- $self->assertTokenValue($self->getToken(), "void", __LINE__);
- return "void";
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- return $self->parseType();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseGet
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "inherits") {
- my $attr = {};
- $self->parseInheritsGetter();
- $attr->{"inherits"} = 1;
- $attr->{"getraises"} = [];
- $attr->{"setraises"} = $self->parseSetRaises();
- return $attr;
- }
- if ($next->value() =~ /$nextGet_1/) {
- return $self->parseSetGetRaises();
- }
-}
-
-sub parseInheritsGetter
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "inherits") {
- $self->assertTokenValue($self->getToken(), "inherits", __LINE__);
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSetGetRaises
-{
- my $self = shift;
- my $attr = {};
- $attr->{"inherits"} = 0;
-
- my $next = $self->nextToken();
- if ($next->value() eq "setter") {
- $attr->{"setraises"} = $self->parseSetRaises();
- $attr->{"getraises"} = $self->parseGetRaises2();
- return $attr;
- }
- if ($next->value() eq "getter") {
- $attr->{"setraises"} = [];
- $attr->{"getraises"} = $self->parseGetRaises();
- return $attr;
- }
- if ($next->value() =~ /$nextSetGetRaises2_1/) {
- return $self->parseSetGetRaises2();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseGetRaises
-{
- my $self = shift;
- my $next = $self->nextToken();
-
- if ($next->value() eq "getter") {
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- $self->assertTokenValue($self->getToken(), "raises", __LINE__);
- return $self->parseExceptionList();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseGetRaises2
-{
- my $self = shift;
- my $next = $self->nextToken();
-
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",", __LINE__);
- $self->assertTokenValue($self->getToken(), "getter", __LINE__);
- $self->assertTokenValue($self->getToken(), "raises", __LINE__);
- return $self->parseExceptionList();
- }
- return [];
-}
-
-sub parseSetRaises
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "setter") {
- $self->assertTokenValue($self->getToken(), "setter", __LINE__);
- $self->assertTokenValue($self->getToken(), "raises", __LINE__);
- return $self->parseExceptionList();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseSetGetRaises2
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextSetGetRaises2_1/) {
- my $attr = {};
- $attr->{"inherits"} = 0;
- $attr->{"getraises"} = $self->parseGetRaises3();
- $attr->{"setraises"} = $self->parseSetRaises3();
- return $attr;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseGetRaises3
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "getraises") {
- $self->assertTokenValue($self->getToken(), "getraises", __LINE__);
- return $self->parseExceptionList();
- }
- return [];
-}
-
-sub parseSetRaises3
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "setraises") {
- $self->assertTokenValue($self->getToken(), "setraises", __LINE__);
- return $self->parseExceptionList();
- }
- return [];
-}
-
-sub parseExceptionList
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "(") {
- my @exceptions = ();
- $self->assertTokenValue($self->getToken(), "(", __LINE__);
- push(@exceptions, @{$self->parseScopedNameList()});
- $self->assertTokenValue($self->getToken(), ")", __LINE__);
- return \@exceptions;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseRaises
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "raises") {
- $self->assertTokenValue($self->getToken(), "raises", __LINE__);
- return $self->parseExceptionList();
- }
- return [];
-}
-
-sub parseDefinitionOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextDefinition_1/) {
- return $self->parseCallbackOrInterfaceOld();
- }
- if ($next->value() eq "partial") {
- return $self->parsePartial({});
- }
- if ($next->value() eq "dictionary") {
- return $self->parseDictionaryOld();
- }
- if ($next->value() eq "exception") {
- return $self->parseExceptionOld();
- }
- if ($next->value() eq "enum") {
- return $self->parseEnumOld();
- }
- if ($next->value() eq "typedef") {
- return $self->parseTypedef({});
- }
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- return $self->parseImplementsStatement({});
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseCallbackOrInterfaceOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "callback") {
- $self->assertTokenValue($self->getToken(), "callback", __LINE__);
- return $self->parseCallbackRestOrInterface({});
- }
- if ($next->value() eq "interface") {
- return $self->parseInterfaceOld();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseInterfaceOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "interface") {
- my $interface = domInterface->new();
- $self->assertTokenValue($self->getToken(), "interface", __LINE__);
- my $extendedAttributeList = $self->parseExtendedAttributeListAllowEmpty();
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- $interface->name($token->value());
- $interface->isException(0);
- push(@{$interface->parents}, @{$self->parseInheritance()});
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- my $interfaceMembers = $self->parseInterfaceMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- applyMemberList($interface, $interfaceMembers);
- applyExtendedAttributeList($interface, $extendedAttributeList);
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseInterfaceMemberOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "const") {
- return $self->parseConst({});
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextInterfaceMemberOld_1/) {
- return $self->parseAttributeOrOperationOrIteratorOld();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseDictionaryOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "dictionary") {
- $self->assertTokenValue($self->getToken(), "dictionary", __LINE__);
- $self->parseExtendedAttributeListAllowEmpty();
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseInheritance();
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseDictionaryMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseDictionaryMemberOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextExceptionField_1/) {
- $self->parseType();
- $self->parseExtendedAttributeListAllowEmpty();
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->parseDefault();
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseExceptionOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "exception") {
- my $interface = domInterface->new();
- $self->assertTokenValue($self->getToken(), "exception", __LINE__);
- my $extendedAttributeList = $self->parseExtendedAttributeListAllowEmpty();
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- $interface->name($token->value());
- $interface->isException(1);
- push(@{$interface->parents}, @{$self->parseInheritance()});
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- my $exceptionMembers = $self->parseInterfaceMembers();
- #$self->parseExceptionMembers();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- applyMemberList($interface, $exceptionMembers);
- applyExtendedAttributeList($interface, $extendedAttributeList);
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseEnumOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "enum") {
- $self->assertTokenValue($self->getToken(), "enum", __LINE__);
- $self->parseExtendedAttributeListAllowEmpty();
- $self->assertTokenType($self->getToken(), IdentifierToken);
- $self->assertTokenValue($self->getToken(), "{", __LINE__);
- $self->parseEnumValueList();
- $self->assertTokenValue($self->getToken(), "}", __LINE__);
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeOrOperationOrIteratorOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "serializer") {
- return $self->parseSerializer({});
- }
- if ($next->value() =~ /$nextAttributeOrOperationOrIterator_1/) {
- my $qualifier = $self->parseQualifier();
- my $interface = $self->parseAttributeOrOperationRestOld();
- if (defined ($interface) && $qualifier eq "static") {
- $interface->isStatic(1);
- }
- return $interface;
- }
- if ($next->value() =~ /$nextAttributeOld_1/) {
- return $self->parseAttributeOld();
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationOrIterator_2/) {
- return $self->parseOperationOrIterator({});
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeOrOperationRestOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeRest_1/) {
- return $self->parseAttributeRestOld();
- }
- if ($next->value() eq ";") {
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return;
- }
- if ($next->type() == IdentifierToken || $next->value() =~ /$nextAttributeOrOperationRest_1/) {
- my $returnType = $self->parseReturnType();
- my $interface = $self->parseOperationRest({});
- if (defined ($interface)) {
- $interface->signature->type($returnType);
- }
- return $interface;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeOld_1/) {
- $self->parseInherit();
- return $self->parseAttributeRestOld();
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseAttributeRestOld
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() =~ /$nextAttributeRest_1/) {
- my $newDataNode = domAttribute->new();
- if ($self->parseReadOnly()) {
- $newDataNode->type("readonly attribute");
- } else {
- $newDataNode->type("attribute");
- }
- $self->assertTokenValue($self->getToken(), "attribute", __LINE__);
- my $extendedAttributeList = $self->parseExtendedAttributeListAllowEmpty();
- $newDataNode->signature(domSignature->new());
- $newDataNode->signature->type($self->parseType());
- $newDataNode->signature->extendedAttributes($extendedAttributeList);
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- $newDataNode->signature->name($token->value());
- my $getRef = $self->parseGet();
- if (defined $getRef) {
- push(@{$newDataNode->getterExceptions}, @{$getRef->{"getraises"}});
- push(@{$newDataNode->setterExceptions}, @{$getRef->{"setraises"}});
- }
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- return $newDataNode;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseIn
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "in") {
- $self->assertTokenValue($self->getToken(), "in", __LINE__);
- return "in";
- }
- return "";
-}
-
-sub parseOptionalSemicolon
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq ";") {
- $self->assertTokenValue($self->getToken(), ";", __LINE__);
- }
-}
-
-sub parseScopedName
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "::") {
- return $self->parseAbsoluteScopedName();
- }
- if ($next->type() == IdentifierToken) {
- return $self->parseRelativeScopedName();
- }
- $self->assertUnexpectedToken($next->value());
-}
-
-sub parseAbsoluteScopedName
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->value() eq "::") {
- $self->assertTokenValue($self->getToken(), "::");
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- return "::" . $token->value() . $self->parseScopedNameParts();
- }
- $self->assertUnexpectedToken($next->value());
-}
-
-sub parseRelativeScopedName
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken) {
- my $token = $self->getToken();
- return $token->value() . $self->parseScopedNameParts();
- }
- $self->assertUnexpectedToken($next->value());
-}
-
-sub parseScopedNameParts
-{
- my $self = shift;
- my @names = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq "::") {
- $self->assertTokenValue($self->getToken(), "::");
- push(@names, "::");
- my $token = $self->getToken();
- $self->assertTokenType($token, IdentifierToken);
- push(@names, $token->value());
- } else {
- last;
- }
- }
- return join("", @names);
-}
-
-sub parseScopedNameList
-{
- my $self = shift;
- my $next = $self->nextToken();
- if ($next->type() == IdentifierToken || $next->value() eq "::") {
- my @names = ();
- push(@names, $self->parseScopedName());
- push(@names, @{$self->parseScopedNames()});
- return \@names;
- }
- $self->assertUnexpectedToken($next->value(), __LINE__);
-}
-
-sub parseScopedNames
-{
- my $self = shift;
- my @names = ();
-
- while (1) {
- my $next = $self->nextToken();
- if ($next->value() eq ",") {
- $self->assertTokenValue($self->getToken(), ",");
- push(@names, $self->parseScopedName());
- } else {
- last;
- }
- }
- return \@names;
-}
-
-sub applyMemberList
-{
- my $interface = shift;
- my $members = shift;
-
- for my $item (@{$members}) {
- if (ref($item) eq "domAttribute") {
- push(@{$interface->attributes}, $item);
- next;
- }
- if (ref($item) eq "domConstant") {
- push(@{$interface->constants}, $item);
- next;
- }
- if (ref($item) eq "domFunction") {
- push(@{$interface->functions}, $item);
- next;
- }
- }
-}
-
-sub applyExtendedAttributeList
-{
- my $interface = shift;
- my $extendedAttributeList = shift;
-
- if (defined $extendedAttributeList->{"Constructors"}) {
- my @constructorParams = @{$extendedAttributeList->{"Constructors"}};
- my $index = (@constructorParams == 1) ? 0 : 1;
- foreach my $param (@constructorParams) {
- my $constructor = domFunction->new();
- $constructor->signature(domSignature->new());
- $constructor->signature->name("Constructor");
- $constructor->signature->extendedAttributes($extendedAttributeList);
- $constructor->parameters($param);
- $constructor->{overloadedIndex} = $index++;
- push(@{$interface->constructors}, $constructor);
- }
- # delete $extendedAttributeList->{"Constructors"};
- # $extendedAttributeList->{"Constructor"} = "VALUE_IS_MISSING";
- } elsif (defined $extendedAttributeList->{"NamedConstructor"}) {
- my $newDataNode = domFunction->new();
- $newDataNode->signature(domSignature->new());
- $newDataNode->signature->name("NamedConstructor");
- $newDataNode->signature->extendedAttributes($extendedAttributeList);
- my %attributes = %{$extendedAttributeList->{"NamedConstructor"}};
- my @attributeKeys = keys (%attributes);
- my $constructorName = $attributeKeys[0];
- push(@{$newDataNode->parameters}, @{$attributes{$constructorName}});
- $extendedAttributeList->{"NamedConstructor"} = $constructorName;
- push(@{$interface->constructors}, $newDataNode);
- }
- $interface->extendedAttributes($extendedAttributeList);
-}
-
-1;
-
diff --git a/contrib/dom/scripts/InFilesCompiler.pm b/contrib/dom/scripts/InFilesCompiler.pm
deleted file mode 100644
index 3dcd772..0000000
--- a/contrib/dom/scripts/InFilesCompiler.pm
+++ /dev/null
@@ -1,296 +0,0 @@
-#!/usr/bin/perl -w
-
-# Copyright (C) 2011 Adam Barth <abarth@webkit.org>
-#
-# 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 GOOGLE, 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.
-#
-
-use strict;
-
-use Config;
-use Getopt::Long;
-use File::Path;
-use File::Spec;
-use IO::File;
-use InFilesParser;
-
-require Config;
-
-package InFilesCompiler;
-
-my $inputFile = "";
-my $outputDir = ".";
-my $defaultItemFactory;
-
-my %parsedItems;
-my %parsedParameters;
-
-sub itemHandler($$$)
-{
- my ($itemName, $property, $value) = @_;
-
- $parsedItems{$itemName} = { &$defaultItemFactory($itemName) } if !defined($parsedItems{$itemName});
-
- return unless $property;
-
- die "Unknown property $property for $itemName\n" if !defined($parsedItems{$itemName}{$property});
- $parsedItems{$itemName}{$property} = $value;
-}
-
-sub parameterHandler($$)
-{
- my ($parameter, $value) = @_;
-
- die "Unknown parameter $parameter\n" if !defined($parsedParameters{$parameter});
- $parsedParameters{$parameter} = $value;
-}
-
-sub new()
-{
- my $object = shift;
- my $reference = { };
-
- my $defaultParametersRef = shift;
- %parsedParameters = %{ $defaultParametersRef };
- $defaultItemFactory = shift;
-
- %parsedItems = ();
-
- bless($reference, $object);
- return $reference;
-}
-
-sub initializeFromCommandLine()
-{
- ::GetOptions(
- 'input=s' => \$inputFile,
- 'outputDir=s' => \$outputDir,
- );
-
- die "You must specify --input <file>" unless length($inputFile);
-
- ::mkpath($outputDir);
-
- # FIXME: Should we provide outputDir via an accessor?
- return $outputDir;
-}
-
-sub compile()
-{
- my $object = shift;
- my $generateCode = shift;
-
- my $file = new IO::File;
- open($file, $inputFile) or die "Failed to open file: $!";
-
- my $InParser = InFilesParser->new();
- $InParser->parse($file, \&parameterHandler, \&itemHandler);
-
- close($file);
- die "Failed to read from file: $inputFile" if (keys %parsedItems == 0);
-
- &$generateCode(\%parsedParameters, \%parsedItems);
-}
-
-sub license()
-{
- return "/*
- * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
- *
- * Copyright (C) 2011 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 GOOGLE, 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.
- */
-
-";
-}
-
-sub interfaceForItem($)
-{
- my $object = shift;
- my $itemName = shift;
-
- my $interfaceName = $parsedItems{$itemName}{"interfaceName"};
- $interfaceName = $itemName unless $interfaceName;
-
- return $interfaceName;
-}
-
-sub toMacroStyle($$)
-{
- my $object = shift;
- my $camelCase = shift;
-
- return "EVENT" if $camelCase eq "Event";
- return "EVENT_TARGET" if $camelCase eq "EventTarget";
- return "EXCEPTION" if $camelCase eq "Exception";
-
- die "Ok, you got me. This script is really just a giant hack. (\$camelCase=${camelCase})";
-}
-
-sub preferredConditional()
-{
- my $object = shift;
- my $conditional = shift;
-
- my @conditionals = split('\\|', $conditional);
- return $conditionals[0];
-}
-
-sub conditionalStringFromAttributeValue()
-{
- my $object = shift;
- my $conditional = shift;
-
- return "ENABLE(" . join(') || ENABLE(', split('\\|', $conditional)) . ")";
-}
-
-sub generateInterfacesHeader()
-{
- my $object = shift;
-
- my $F;
- my $namespace = $parsedParameters{"namespace"};
- my $outputFile = "$outputDir/${namespace}Interfaces.h";
-
- open F, ">$outputFile" or die "Failed to open file: $!";
-
- print F license();
-
- print F "#ifndef ${namespace}Interfaces_h\n";
- print F "#define ${namespace}Interfaces_h\n";
- print F "\n";
-
- my %unconditionalInterfaces = ();
- my %interfacesByConditional = ();
-
- for my $itemName (sort keys %parsedItems) {
- my $conditional = $parsedItems{$itemName}{"conditional"};
- my $interfaceName = $object->interfaceForItem($itemName);
-
- if ($conditional) {
- if (!defined($interfacesByConditional{$conditional})) {
- $interfacesByConditional{$conditional} = ();
- }
- $interfacesByConditional{$conditional}{$interfaceName} = 1;
- } else {
- $unconditionalInterfaces{$interfaceName} = 1
- }
- }
-
- my $macroStyledNamespace = $object->toMacroStyle($namespace);
-
- for my $conditional (sort keys %interfacesByConditional) {
- my $preferredConditional = $object->preferredConditional($conditional);
- print F "#if " . $object->conditionalStringFromAttributeValue($conditional) . "\n";
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro) \\\n";
-
- for my $interface (sort keys %{ $interfacesByConditional{$conditional} }) {
- next if defined($unconditionalInterfaces{$interface});
- print F " macro($interface) \\\n";
- }
-
- print F "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional\n";
- print F "#else\n";
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro)\n";
- print F "#endif\n";
- print F "\n";
- }
-
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH(macro) \\\n";
- print F " \\\n";
- for my $interface (sort keys %unconditionalInterfaces) {
- print F " macro($interface) \\\n";
- }
- print F " \\\n";
- for my $conditional (sort keys %interfacesByConditional) {
- my $preferredConditional = $object->preferredConditional($conditional);
- print F " DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$preferredConditional(macro) \\\n";
- }
-
- print F "\n";
- print F "#endif // ${namespace}Interfaces_h\n";
-
- close F;
-}
-
-sub generateHeadersHeader()
-{
- my $object = shift;
-
- my $F;
- my $namespace = $parsedParameters{"namespace"};
- my $outputFile = "$outputDir/${namespace}Headers.h";
-
- open F, ">$outputFile" or die "Failed to open file: $!";
-
- print F license();
-
- print F "#ifndef ${namespace}Headers_h\n";
- print F "#define ${namespace}Headers_h\n";
- print F "\n";
-
- my %includedInterfaces = ();
-
- for my $itemName (sort keys %parsedItems) {
- my $conditional = $parsedItems{$itemName}{"conditional"};
- my $interfaceName = $object->interfaceForItem($itemName);
-
- next if defined($includedInterfaces{$interfaceName});
- $includedInterfaces{$interfaceName} = 1;
-
- print F "#if " . $object->conditionalStringFromAttributeValue($conditional) . "\n" if $conditional;
- print F "#include \"$interfaceName.h\"\n";
- print F "#if USE(JSC)\n";
- print F "#include \"JS$interfaceName.h\"\n";
- print F "#elif USE(V8)\n";
- print F "#include \"V8$interfaceName.h\"\n";
- print F "#endif\n";
- print F "#endif\n" if $conditional;
- }
-
- print F "\n";
- print F "#endif // ${namespace}Headers_h\n";
-
- close F;
-}
-
-1;
diff --git a/contrib/dom/scripts/InFilesParser.pm b/contrib/dom/scripts/InFilesParser.pm
deleted file mode 100644
index 6539380..0000000
--- a/contrib/dom/scripts/InFilesParser.pm
+++ /dev/null
@@ -1,154 +0,0 @@
-#!/usr/bin/perl -w
-
-# Copyright (C) 2008 Julien Chaffraix <jchaffraix@webkit.org>
-#
-# 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.
-#
-
-use strict;
-
-package InFilesParser;
-
-my $isParsingCommonParameters;
-my $hasStartedParsing;
-
-# Helper functions
-
-sub trimComment
-{
- my $string = shift;
- $string =~ s/#.+$//;
- chomp($string);
- return $string;
-}
-
-sub trimWS
-{
- my $string = shift;
- $string =~ s/^\s+//;
- $string =~ s/\s+$//;
- chomp($string);
- return $string;
-}
-
-sub trimQuoteAndWS
-{
- my $string = shift;
- $string =~ s/\"([^\"]+)\"/$1/;
- return trimWS($string);
-}
-
-# Default constructor
-
-sub new
-{
- my $object = shift;
- my $reference = { };
-
- # Initialize the parser.
- $isParsingCommonParameters = 1;
- $hasStartedParsing = 0;
-
- bless($reference, $object);
- return $reference;
-}
-
-# parse take 3 attributes:
-# - the filestream to read from (the caller has to open / close it).
-# - the commonParameterHandler called when parsing the first part of the file with the parameter and the value.
-# - the perTagHandler called for each optional parameter with the element name, the parameter and its value.
-# If no parameter were provided, it is called once with an empty parameter and value.
-sub parse($)
-{
- my $object = shift;
- my $fileStream = shift; # IO::File only
- my $commonParameterHandler = shift;
- my $perTagHandler = shift;
-
- foreach (<$fileStream>) {
- # Ignore whitespace, in case the .in files have the wrong EOL
- # markers and those are getting treated as whitespace.
- $_ = trimWS($_);
-
- # Empty line, change from common parameter part
- # to per tag part if we have started parsing.
- if (/^$/) {
- if ($hasStartedParsing) {
- $isParsingCommonParameters = 0;
- }
- next;
- }
-
- # There may be a few empty lines at the beginning of the file
- # so detect the first non empty line which starts the common
- # parameters part.
- $hasStartedParsing = 1;
-
- if (/^#/) {
- next;
- }
-
- $_ = trimComment($_);
-
- if ($isParsingCommonParameters) {
- my ($name, $value) = split '=', $_;
-
- $name = trimWS($name);
- if (defined($value)) {
- $value = trimQuoteAndWS($value);
- } else {
- # We default to 1 as it eases the syntax.
- $value = "1";
- }
-
- &$commonParameterHandler($name, $value);
- } else {
- # Parsing per-tag parameters.
-
- # Split the tag name ($1) from the optionnal parameter(s) ($2)
- /^(\S+)\s*(.*)$/;
- my $elementName = $1;
-
- if ($2) {
- my @options = split "," , $2;
- my ($option, $value);
- for (my $i = 0; $i < @options; ++$i) {
- ($option, $value) = split "=", $options[$i];
- $option = trimWS($option);
- if (defined($value)) {
- $value = trimQuoteAndWS($value);
- } else {
- # We default to 1 as it eases the syntax.
- $value = "1";
- }
-
- &$perTagHandler($elementName, $option, $value);
- }
- } else {
- # No parameter was given so call it with empty strings.
- &$perTagHandler($elementName, "", "");
- }
- }
- }
-}
-
-1;
diff --git a/contrib/dom/scripts/generate-bindings.pl b/contrib/dom/scripts/generate-bindings.pl
deleted file mode 100755
index ecf0218..0000000
--- a/contrib/dom/scripts/generate-bindings.pl
+++ /dev/null
@@ -1,217 +0,0 @@
-#!/usr/bin/perl -w
-#
-# Copyright (C) 2005 Apple Computer, Inc.
-# Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
-#
-# This file is part of WebKit
-#
-# 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.
-#
-
-# This script is a temporary hack.
-# Files are generated in the source directory, when they really should go
-# to the DerivedSources directory.
-# This should also eventually be a build rule driven off of .idl files
-# however a build rule only solution is blocked by several radars:
-# <rdar://problems/4251781&4251785>
-
-use strict;
-
-use File::Path;
-use File::Basename;
-use Getopt::Long;
-use Text::ParseWords;
-use Data::Dumper;
-use Cwd;
-
-use IDLParser;
-use CodeGenerator;
-
-my @idlDirectories;
-my $outputDirectory;
-my $outputHeadersDirectory;
-my $generator;
-my $defines;
-my $filename;
-my $prefix;
-my $preprocessor;
-my $writeDependencies;
-my $verbose;
-my $supplementalDependencyFile;
-my $additionalIdlFiles;
-
-GetOptions('include=s@' => \@idlDirectories,
- 'outputDir=s' => \$outputDirectory,
- 'outputHeadersDir=s' => \$outputHeadersDirectory,
- 'generator=s' => \$generator,
- 'defines=s' => \$defines,
- 'filename=s' => \$filename,
- 'prefix=s' => \$prefix,
- 'preprocessor=s' => \$preprocessor,
- 'verbose' => \$verbose,
- 'write-dependencies' => \$writeDependencies,
- 'supplementalDependencyFile=s' => \$supplementalDependencyFile,
- 'additionalIdlFiles=s' => \$additionalIdlFiles);
-
-my $targetIdlFile = $ARGV[0];
-
-print "$targetIdlFile\n";
-
-die('Must specify input file.') unless defined($targetIdlFile);
-die('Must specify generator') unless defined($generator);
-die('Must specify output directory.') unless defined($outputDirectory);
-
-if (!$outputHeadersDirectory) {
- $outputHeadersDirectory = $outputDirectory;
-}
-$targetIdlFile = Cwd::realpath($targetIdlFile);
-if ($verbose) {
- print "$generator: $targetIdlFile\n";
-}
-my $targetInterfaceName = fileparse(basename($targetIdlFile), ".idl");
-
-my $idlFound = 0;
-my @supplementedIdlFiles;
-if ($supplementalDependencyFile) {
- # The format of a supplemental dependency file:
- #
- # DOMWindow.idl P.idl Q.idl R.idl
- # Document.idl S.idl
- # Event.idl
- # ...
- #
- # The above indicates that DOMWindow.idl is supplemented by P.idl, Q.idl and R.idl,
- # Document.idl is supplemented by S.idl, and Event.idl is supplemented by no IDLs.
- # The IDL that supplements another IDL (e.g. P.idl) never appears in the dependency file.
- open FH, "< $supplementalDependencyFile" or die "Cannot open $supplementalDependencyFile\n";
- while (my $line = <FH>) {
- my ($idlFile, @followingIdlFiles) = split(/\s+/, $line);
- if ($idlFile and basename($idlFile) eq basename($targetIdlFile)) {
- $idlFound = 1;
- @supplementedIdlFiles = @followingIdlFiles;
- }
- }
- close FH;
-
- # $additionalIdlFiles is list of IDL files which should not be included in
- # DerivedSources*.cpp (i.e. they are not described in the supplemental
- # dependency file) but should generate .h and .cpp files.
- if (!$idlFound and $additionalIdlFiles) {
- my @idlFiles = shellwords($additionalIdlFiles);
- $idlFound = grep { $_ and basename($_) eq basename($targetIdlFile) } @idlFiles;
- }
-
- if (!$idlFound) {
- my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose);
-
- # We generate empty .h and .cpp files just to tell build scripts that .h and .cpp files are created.
- generateEmptyHeaderAndCpp($codeGen->FileNamePrefix(), $targetInterfaceName, $outputHeadersDirectory, $outputDirectory);
- exit 0;
- }
-}
-
-# Parse the target IDL file.
-my $targetParser = IDLParser->new(!$verbose);
-my $targetDocument = $targetParser->Parse($targetIdlFile, $defines, $preprocessor);
-
-# print Dumper($targetDocument);
-# exit;
-
-foreach my $idlFile (@supplementedIdlFiles) {
- next if $idlFile eq $targetIdlFile;
-
- my $interfaceName = fileparse(basename($idlFile), ".idl");
- my $parser = IDLParser->new(!$verbose);
- my $document = $parser->Parse($idlFile, $defines, $preprocessor);
-
- foreach my $interface (@{$document->interfaces}) {
- if ($interface->extendedAttributes->{"Supplemental"} and $interface->extendedAttributes->{"Supplemental"} eq $targetInterfaceName) {
- my $targetDataNode;
- foreach my $interface (@{$targetDocument->interfaces}) {
- if ($interface->name eq $targetInterfaceName) {
- $targetDataNode = $interface;
- last;
- }
- }
- die "Not found an interface ${targetInterfaceName} in ${targetInterfaceName}.idl." unless defined $targetDataNode;
-
- # Support [Supplemental] for attributes.
- foreach my $attribute (@{$interface->attributes}) {
- # Record that this attribute is implemented by $interfaceName.
- $attribute->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
-
- # Add interface-wide extended attributes to each attribute.
- foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
- next if ($extendedAttributeName eq "Supplemental");
- $attribute->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
- }
- push(@{$targetDataNode->attributes}, $attribute);
- }
-
- # Support [Supplemental] for methods.
- foreach my $function (@{$interface->functions}) {
- # Record that this method is implemented by $interfaceName.
- $function->signature->extendedAttributes->{"ImplementedBy"} = $interfaceName;
-
- # Add interface-wide extended attributes to each method.
- foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
- next if ($extendedAttributeName eq "Supplemental");
- $function->signature->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
- }
- push(@{$targetDataNode->functions}, $function);
- }
-
- # Support [Supplemental] for constants.
- foreach my $constant (@{$interface->constants}) {
- # Record that this constant is implemented by $interfaceName.
- $constant->extendedAttributes->{"ImplementedBy"} = $interfaceName;
-
- # Add interface-wide extended attributes to each constant.
- foreach my $extendedAttributeName (keys %{$interface->extendedAttributes}) {
- next if ($extendedAttributeName eq "Supplemental");
- $constant->extendedAttributes->{$extendedAttributeName} = $interface->extendedAttributes->{$extendedAttributeName};
- }
- push(@{$targetDataNode->constants}, $constant);
- }
- }
- }
-}
-
-# Generate desired output for the target IDL file.
-my $codeGen = CodeGenerator->new(\@idlDirectories, $generator, $outputDirectory, $outputHeadersDirectory, 0, $preprocessor, $writeDependencies, $verbose, $targetIdlFile);
-$codeGen->ProcessDocument($targetDocument, $defines);
-
-sub generateEmptyHeaderAndCpp
-{
- my ($prefix, $targetInterfaceName, $outputHeadersDirectory, $outputDirectory) = @_;
-
- my $headerName = "${prefix}${targetInterfaceName}.h";
- my $cppName = "${prefix}${targetInterfaceName}.cpp";
- my $contents = "/*
- This file is generated just to tell build scripts that $headerName and
- $cppName are created for ${targetInterfaceName}.idl, and thus
- prevent the build scripts from trying to generate $headerName and
- $cppName at every build. This file must not be tried to compile.
-*/
-";
- open FH, "> ${outputHeadersDirectory}/${headerName}" or die "Cannot open $headerName\n";
- print FH $contents;
- close FH;
-
- open FH, "> ${outputDirectory}/${cppName}" or die "Cannot open $cppName\n";
- print FH $contents;
- close FH;
-}
diff --git a/contrib/dom/scripts/make_jsc.sh b/contrib/dom/scripts/make_jsc.sh
deleted file mode 100755
index 465e382..0000000
--- a/contrib/dom/scripts/make_jsc.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-find ../idl/ -name *.idl -exec ./generate-bindings.pl --outputDir=/Users/sradomski/Documents/TK/Code/uscxml/src/uscxml/plugins/datamodel/ecmascript/JavaScriptCore/dom --include=../idl/ --generator=ArabicaJSC {} \;
diff --git a/contrib/dom/scripts/make_v8.sh b/contrib/dom/scripts/make_v8.sh
deleted file mode 100755
index 0d17f88..0000000
--- a/contrib/dom/scripts/make_v8.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-find ../idl/ -name *.idl -exec ./generate-bindings.pl --outputDir=/Users/sradomski/Documents/TK/Code/uscxml/src/uscxml/plugins/datamodel/ecmascript/v8/dom --include=../idl/ --generator=ArabicaV8 {} \;
diff --git a/contrib/dom/scripts/preprocessor.pm b/contrib/dom/scripts/preprocessor.pm
deleted file mode 100644
index 5f67539..0000000
--- a/contrib/dom/scripts/preprocessor.pm
+++ /dev/null
@@ -1,89 +0,0 @@
-#
-# Copyright (C) 2005 Nikolas Zimmermann <wildfox@kde.org>
-# Copyright (C) 2011 Google Inc.
-#
-# 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.
-#
-
-use strict;
-use warnings;
-
-use Config;
-use IPC::Open2;
-use IPC::Open3;
-
-BEGIN {
- use Exporter ();
- our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
- $VERSION = 1.00;
- @ISA = qw(Exporter);
- @EXPORT = qw(&applyPreprocessor);
- %EXPORT_TAGS = ( );
- @EXPORT_OK = ();
-}
-
-# Returns an array of lines.
-sub applyPreprocessor
-{
- my $fileName = shift;
- my $defines = shift || "";
- my $preprocessor = shift;
-
- my @args = ();
- if (!$preprocessor) {
- require Config;
- if ($ENV{CC}) {
- $preprocessor = $ENV{CC};
- } elsif (($Config::Config{'osname'}) =~ /solaris/i) {
- $preprocessor = "/usr/sfw/bin/gcc";
- } else {
- $preprocessor = "/usr/bin/gcc";
- }
- push(@args, qw(-E -P -x c++));
- }
-
- # Remove double quotations from $defines and extract macros.
- # For example, if $defines is ' "A=1" "B=1" C=1 "" D ',
- # then it is converted into four macros -DA=1, -DB=1, -DC=1 and -DD.
- $defines =~ s/\"//g;
- my @macros = grep { $_ } split(/\s+/, $defines); # grep skips empty macros.
- @macros = map { "-D$_" } @macros;
-
- my $pid = 0;
- if ($Config{osname} eq "cygwin" || $Config{osname} eq 'MSWin32') {
- # This call can fail if Windows rebases cygwin, so retry a few times until it succeeds.
- for (my $tries = 0; !$pid && ($tries < 20); $tries++) {
- eval {
- # Suppress STDERR so that if we're using cl.exe, the output
- # name isn't needlessly echoed.
- use Symbol 'gensym'; my $err = gensym;
- $pid = open3(\*PP_IN, \*PP_OUT, $err, split(' ', $preprocessor), @args, @macros, $fileName);
- 1;
- } or do {
- sleep 1;
- }
- };
- } else {
- $pid = open2(\*PP_OUT, \*PP_IN, split(' ', $preprocessor), @args, @macros, $fileName);
- }
- close PP_IN;
- my @documentContent = <PP_OUT>;
- close PP_OUT;
- waitpid($pid, 0);
- return @documentContent;
-}
-
-1;