update the DOM API so that we implement using the property style access of properties which work natively in JS and avoid using getter/setter methods in the DOM library so that they can easily compile to JS too from the same org.w3c.dom API on the JVM
This commit is contained in:
+214
-197
@@ -12,274 +12,291 @@ import js.noImpl
|
||||
|
||||
|
||||
native public trait Attr: Node {
|
||||
fun getName(): String = js.noImpl
|
||||
fun getValue(): String = js.noImpl
|
||||
fun setValue(arg1: String): Unit = js.noImpl
|
||||
fun getSchemaTypeInfo(): TypeInfo = js.noImpl
|
||||
fun getSpecified(): Boolean = js.noImpl
|
||||
fun getOwnerElement(): Element = js.noImpl
|
||||
fun isId(): Boolean = js.noImpl
|
||||
public val name: String
|
||||
public val ownerElement: Element
|
||||
public val schemaTypeInfo: TypeInfo
|
||||
public val specified: Boolean
|
||||
public val value: String
|
||||
public fun setValue(arg1: String): Unit = js.noImpl
|
||||
public fun isId(): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait CDATASection: Text {
|
||||
}
|
||||
|
||||
native public trait CharacterData: Node {
|
||||
fun getLength(): Int = js.noImpl
|
||||
fun getData(): String = js.noImpl
|
||||
fun replaceData(arg1: Int, arg2: Int, arg3: String): Unit = js.noImpl
|
||||
fun setData(arg1: String): Unit = js.noImpl
|
||||
fun substringData(arg1: Int, arg2: Int): String = js.noImpl
|
||||
fun appendData(arg1: String): Unit = js.noImpl
|
||||
fun insertData(arg1: Int, arg2: String): Unit = js.noImpl
|
||||
fun deleteData(arg1: Int, arg2: Int): Unit = js.noImpl
|
||||
public val data: String
|
||||
public val length: Int
|
||||
public fun replaceData(arg1: Int, arg2: Int, arg3: String): Unit = js.noImpl
|
||||
public fun setData(arg1: String): Unit = js.noImpl
|
||||
public fun substringData(arg1: Int, arg2: Int): String = js.noImpl
|
||||
public fun appendData(arg1: String): Unit = js.noImpl
|
||||
public fun insertData(arg1: Int, arg2: String): Unit = js.noImpl
|
||||
public fun deleteData(arg1: Int, arg2: Int): Unit = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Comment: CharacterData {
|
||||
}
|
||||
|
||||
native public trait Document: Node {
|
||||
fun getImplementation(): DOMImplementation = js.noImpl
|
||||
fun getInputEncoding(): String = js.noImpl
|
||||
fun getXmlEncoding(): String = js.noImpl
|
||||
fun createElement(arg1: String): Element = js.noImpl
|
||||
fun createComment(arg1: String): Comment = js.noImpl
|
||||
fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
fun getDoctype(): DocumentType = js.noImpl
|
||||
fun getDocumentElement(): Element = js.noImpl
|
||||
fun createDocumentFragment(): DocumentFragment = js.noImpl
|
||||
fun createTextNode(arg1: String): Text = js.noImpl
|
||||
fun createCDATASection(arg1: String): CDATASection = js.noImpl
|
||||
fun createProcessingInstruction(arg1: String, arg2: String): ProcessingInstruction = js.noImpl
|
||||
fun createAttribute(arg1: String): Attr = js.noImpl
|
||||
fun createEntityReference(arg1: String): EntityReference = js.noImpl
|
||||
fun importNode(arg1: Node, arg2: Boolean): Node = js.noImpl
|
||||
fun createElementNS(arg1: String, arg2: String): Element = js.noImpl
|
||||
fun createAttributeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
fun getElementById(arg1: String): Element = js.noImpl
|
||||
fun getXmlStandalone(): Boolean = js.noImpl
|
||||
fun setXmlStandalone(arg1: Boolean): Unit = js.noImpl
|
||||
fun getXmlVersion(): String = js.noImpl
|
||||
fun setXmlVersion(arg1: String): Unit = js.noImpl
|
||||
fun getStrictErrorChecking(): Boolean = js.noImpl
|
||||
fun setStrictErrorChecking(arg1: Boolean): Unit = js.noImpl
|
||||
fun getDocumentURI(): String = js.noImpl
|
||||
fun setDocumentURI(arg1: String): Unit = js.noImpl
|
||||
fun adoptNode(arg1: Node): Node = js.noImpl
|
||||
fun getDomConfig(): DOMConfiguration = js.noImpl
|
||||
fun normalizeDocument(): Unit = js.noImpl
|
||||
fun renameNode(arg1: Node, arg2: String, arg3: String): Node = js.noImpl
|
||||
public val doctype: DocumentType
|
||||
public val documentElement: Element
|
||||
public val documentURI: String
|
||||
public val domConfig: DOMConfiguration
|
||||
public val implementation: DOMImplementation
|
||||
public val inputEncoding: String
|
||||
public val strictErrorChecking: Boolean
|
||||
public val xmlEncoding: String
|
||||
public val xmlStandalone: Boolean
|
||||
public val xmlVersion: String
|
||||
public fun createElement(arg1: String): Element = js.noImpl
|
||||
public fun createComment(arg1: String): Comment = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
public fun createDocumentFragment(): DocumentFragment = js.noImpl
|
||||
public fun createTextNode(arg1: String): Text = js.noImpl
|
||||
public fun createCDATASection(arg1: String): CDATASection = js.noImpl
|
||||
public fun createProcessingInstruction(arg1: String, arg2: String): ProcessingInstruction = js.noImpl
|
||||
public fun createAttribute(arg1: String): Attr = js.noImpl
|
||||
public fun createEntityReference(arg1: String): EntityReference = js.noImpl
|
||||
public fun importNode(arg1: Node, arg2: Boolean): Node = js.noImpl
|
||||
public fun createElementNS(arg1: String, arg2: String): Element = js.noImpl
|
||||
public fun createAttributeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
public fun getElementById(arg1: String): Element = js.noImpl
|
||||
public fun setXmlStandalone(arg1: Boolean): Unit = js.noImpl
|
||||
public fun setXmlVersion(arg1: String): Unit = js.noImpl
|
||||
public fun setStrictErrorChecking(arg1: Boolean): Unit = js.noImpl
|
||||
public fun setDocumentURI(arg1: String): Unit = js.noImpl
|
||||
public fun adoptNode(arg1: Node): Node = js.noImpl
|
||||
public fun normalizeDocument(): Unit = js.noImpl
|
||||
public fun renameNode(arg1: Node, arg2: String, arg3: String): Node = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DocumentFragment: Node {
|
||||
}
|
||||
|
||||
native public trait DocumentType: Node {
|
||||
fun getName(): String = js.noImpl
|
||||
fun getEntities(): NamedNodeMap = js.noImpl
|
||||
fun getNotations(): NamedNodeMap = js.noImpl
|
||||
fun getPublicId(): String = js.noImpl
|
||||
fun getSystemId(): String = js.noImpl
|
||||
fun getInternalSubset(): String = js.noImpl
|
||||
public val entities: NamedNodeMap
|
||||
public val internalSubset: String
|
||||
public val name: String
|
||||
public val notations: NamedNodeMap
|
||||
public val publicId: String
|
||||
public val systemId: String
|
||||
}
|
||||
|
||||
native public trait DOMConfiguration {
|
||||
fun setParameter(arg1: String, arg2: Any): Unit = js.noImpl
|
||||
fun getParameter(arg1: String): Any = js.noImpl
|
||||
fun canSetParameter(arg1: String, arg2: Any): Boolean = js.noImpl
|
||||
fun getParameterNames(): DOMStringList = js.noImpl
|
||||
public val parameterNames: DOMStringList
|
||||
public fun setParameter(arg1: String, arg2: Any): Unit = js.noImpl
|
||||
public fun getParameter(arg1: String): Any = js.noImpl
|
||||
public fun canSetParameter(arg1: String, arg2: Any): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMError {
|
||||
fun getLocation(): DOMLocator = js.noImpl
|
||||
fun getMessage(): String = js.noImpl
|
||||
fun getType(): String = js.noImpl
|
||||
fun getSeverity(): Short = js.noImpl
|
||||
fun getRelatedException(): Any = js.noImpl
|
||||
fun getRelatedData(): Any = js.noImpl
|
||||
public val SEVERITY_WARNING: Short
|
||||
public val SEVERITY_ERROR: Short
|
||||
public val SEVERITY_FATAL_ERROR: Short
|
||||
public val `type`: String
|
||||
public val location: DOMLocator
|
||||
public val message: String
|
||||
public val relatedData: Any
|
||||
public val relatedException: Any
|
||||
public val severity: Short
|
||||
|
||||
class object {
|
||||
public val SEVERITY_WARNING: Short = 1
|
||||
public val SEVERITY_ERROR: Short = 2
|
||||
public val SEVERITY_FATAL_ERROR: Short = 3
|
||||
}
|
||||
}
|
||||
|
||||
native public trait DOMErrorHandler {
|
||||
fun handleError(arg1: DOMError): Boolean = js.noImpl
|
||||
public fun handleError(arg1: DOMError): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMImplementation {
|
||||
fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
fun hasFeature(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
fun createDocumentType(arg1: String, arg2: String, arg3: String): DocumentType = js.noImpl
|
||||
fun createDocument(arg1: String, arg2: String, arg3: DocumentType): Document = js.noImpl
|
||||
public fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
public fun hasFeature(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun createDocumentType(arg1: String, arg2: String, arg3: String): DocumentType = js.noImpl
|
||||
public fun createDocument(arg1: String, arg2: String, arg3: DocumentType): Document = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMImplementationList {
|
||||
public val length: Int
|
||||
public fun item(arg1: Int): DOMImplementation = js.noImpl
|
||||
}
|
||||
|
||||
native public trait DOMLocator {
|
||||
fun getLineNumber(): Int = js.noImpl
|
||||
fun getColumnNumber(): Int = js.noImpl
|
||||
fun getByteOffset(): Int = js.noImpl
|
||||
fun getUtf16Offset(): Int = js.noImpl
|
||||
fun getRelatedNode(): Node = js.noImpl
|
||||
fun getUri(): String = js.noImpl
|
||||
public val byteOffset: Int
|
||||
public val columnNumber: Int
|
||||
public val lineNumber: Int
|
||||
public val relatedNode: Node
|
||||
public val uri: String
|
||||
public val utf16Offset: Int
|
||||
}
|
||||
|
||||
native public trait DOMStringList {
|
||||
fun getLength(): Int = js.noImpl
|
||||
fun contains(arg1: String): Boolean = js.noImpl
|
||||
fun item(arg1: Int): String = js.noImpl
|
||||
public val length: Int
|
||||
public fun contains(arg1: String): Boolean = js.noImpl
|
||||
public fun item(arg1: Int): String = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Element: Node {
|
||||
fun getAttribute(arg1: String): String = js.noImpl
|
||||
fun setAttribute(arg1: String, arg2: String): Unit = js.noImpl
|
||||
fun getTagName(): String = js.noImpl
|
||||
fun removeAttribute(arg1: String): Unit = js.noImpl
|
||||
fun getAttributeNode(arg1: String): Attr = js.noImpl
|
||||
fun setAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
fun removeAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
fun getAttributeNS(arg1: String, arg2: String): String = js.noImpl
|
||||
fun setAttributeNS(arg1: String, arg2: String, arg3: String): Unit = js.noImpl
|
||||
fun removeAttributeNS(arg1: String, arg2: String): Unit = js.noImpl
|
||||
fun getAttributeNodeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
fun setAttributeNodeNS(arg1: Attr): Attr = js.noImpl
|
||||
fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
fun hasAttribute(arg1: String): Boolean = js.noImpl
|
||||
fun hasAttributeNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
fun getSchemaTypeInfo(): TypeInfo = js.noImpl
|
||||
fun setIdAttribute(arg1: String, arg2: Boolean): Unit = js.noImpl
|
||||
fun setIdAttributeNS(arg1: String, arg2: String, arg3: Boolean): Unit = js.noImpl
|
||||
fun setIdAttributeNode(arg1: Attr, arg2: Boolean): Unit = js.noImpl
|
||||
public val schemaTypeInfo: TypeInfo
|
||||
public val tagName: String
|
||||
public fun getAttribute(arg1: String): String = js.noImpl
|
||||
public fun setAttribute(arg1: String, arg2: String): Unit = js.noImpl
|
||||
public fun removeAttribute(arg1: String): Unit = js.noImpl
|
||||
public fun getAttributeNode(arg1: String): Attr = js.noImpl
|
||||
public fun setAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun removeAttributeNode(arg1: Attr): Attr = js.noImpl
|
||||
public fun getElementsByTagName(arg1: String): NodeList = js.noImpl
|
||||
public fun getAttributeNS(arg1: String, arg2: String): String = js.noImpl
|
||||
public fun setAttributeNS(arg1: String, arg2: String, arg3: String): Unit = js.noImpl
|
||||
public fun removeAttributeNS(arg1: String, arg2: String): Unit = js.noImpl
|
||||
public fun getAttributeNodeNS(arg1: String, arg2: String): Attr = js.noImpl
|
||||
public fun setAttributeNodeNS(arg1: Attr): Attr = js.noImpl
|
||||
public fun getElementsByTagNameNS(arg1: String, arg2: String): NodeList = js.noImpl
|
||||
public fun hasAttribute(arg1: String): Boolean = js.noImpl
|
||||
public fun hasAttributeNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun setIdAttribute(arg1: String, arg2: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNS(arg1: String, arg2: String, arg3: Boolean): Unit = js.noImpl
|
||||
public fun setIdAttributeNode(arg1: Attr, arg2: Boolean): Unit = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Entity: Node {
|
||||
fun getInputEncoding(): String = js.noImpl
|
||||
fun getXmlEncoding(): String = js.noImpl
|
||||
fun getXmlVersion(): String = js.noImpl
|
||||
fun getPublicId(): String = js.noImpl
|
||||
fun getSystemId(): String = js.noImpl
|
||||
fun getNotationName(): String = js.noImpl
|
||||
public val inputEncoding: String
|
||||
public val notationName: String
|
||||
public val publicId: String
|
||||
public val systemId: String
|
||||
public val xmlEncoding: String
|
||||
public val xmlVersion: String
|
||||
}
|
||||
|
||||
native public trait EntityReference: Node {
|
||||
}
|
||||
|
||||
native public trait NameList {
|
||||
fun getLength(): Int = js.noImpl
|
||||
fun getName(arg1: Int): String = js.noImpl
|
||||
fun contains(arg1: String): Boolean = js.noImpl
|
||||
fun getNamespaceURI(arg1: Int): String = js.noImpl
|
||||
fun containsNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public val length: Int
|
||||
public fun getName(arg1: Int): String = js.noImpl
|
||||
public fun contains(arg1: String): Boolean = js.noImpl
|
||||
public fun getNamespaceURI(arg1: Int): String = js.noImpl
|
||||
public fun containsNS(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
}
|
||||
|
||||
native public trait NamedNodeMap {
|
||||
fun getLength(): Int = js.noImpl
|
||||
fun item(arg1: Int): Node = js.noImpl
|
||||
fun getNamedItem(arg1: String): Node = js.noImpl
|
||||
fun setNamedItem(arg1: Node): Node = js.noImpl
|
||||
fun removeNamedItem(arg1: String): Node = js.noImpl
|
||||
fun getNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
fun setNamedItemNS(arg1: Node): Node = js.noImpl
|
||||
fun removeNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
public val length: Int
|
||||
public fun item(arg1: Int): Node = js.noImpl
|
||||
public fun getNamedItem(arg1: String): Node = js.noImpl
|
||||
public fun setNamedItem(arg1: Node): Node = js.noImpl
|
||||
public fun removeNamedItem(arg1: String): Node = js.noImpl
|
||||
public fun getNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
public fun setNamedItemNS(arg1: Node): Node = js.noImpl
|
||||
public fun removeNamedItemNS(arg1: String, arg2: String): Node = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Node {
|
||||
fun normalize(): Unit = js.noImpl
|
||||
fun isSupported(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
fun getAttributes(): NamedNodeMap = js.noImpl
|
||||
fun getUserData(arg1: String): Any = js.noImpl
|
||||
fun setUserData(arg1: String, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
fun getPrefix(): String = js.noImpl
|
||||
fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
fun hasAttributes(): Boolean = js.noImpl
|
||||
fun setPrefix(arg1: String): Unit = js.noImpl
|
||||
fun removeChild(arg1: Node): Node = js.noImpl
|
||||
fun replaceChild(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
fun getFirstChild(): Node = js.noImpl
|
||||
fun getLastChild(): Node = js.noImpl
|
||||
fun getNextSibling(): Node = js.noImpl
|
||||
fun insertBefore(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
fun getLocalName(): String = js.noImpl
|
||||
fun getNodeName(): String = js.noImpl
|
||||
fun getNodeValue(): String = js.noImpl
|
||||
fun setNodeValue(arg1: String): Unit = js.noImpl
|
||||
fun getNodeType(): Short = js.noImpl
|
||||
fun getParentNode(): Node = js.noImpl
|
||||
fun getChildNodes(): NodeList = js.noImpl
|
||||
fun getPreviousSibling(): Node = js.noImpl
|
||||
fun getOwnerDocument(): Document = js.noImpl
|
||||
fun appendChild(arg1: Node): Node = js.noImpl
|
||||
fun hasChildNodes(): Boolean = js.noImpl
|
||||
fun cloneNode(arg1: Boolean): Node = js.noImpl
|
||||
fun getNamespaceURI(): String = js.noImpl
|
||||
fun getBaseURI(): String = js.noImpl
|
||||
fun compareDocumentPosition(arg1: Node): Short = js.noImpl
|
||||
fun getTextContent(): String = js.noImpl
|
||||
fun setTextContent(arg1: String): Unit = js.noImpl
|
||||
fun isSameNode(arg1: Node): Boolean = js.noImpl
|
||||
fun lookupPrefix(arg1: String): String = js.noImpl
|
||||
fun isDefaultNamespace(arg1: String): Boolean = js.noImpl
|
||||
fun lookupNamespaceURI(arg1: String): String = js.noImpl
|
||||
fun isEqualNode(arg1: Node): Boolean = js.noImpl
|
||||
public val ELEMENT_NODE: Short
|
||||
public val ATTRIBUTE_NODE: Short
|
||||
public val TEXT_NODE: Short
|
||||
public val CDATA_SECTION_NODE: Short
|
||||
public val ENTITY_REFERENCE_NODE: Short
|
||||
public val ENTITY_NODE: Short
|
||||
public val PROCESSING_INSTRUCTION_NODE: Short
|
||||
public val COMMENT_NODE: Short
|
||||
public val DOCUMENT_NODE: Short
|
||||
public val DOCUMENT_TYPE_NODE: Short
|
||||
public val DOCUMENT_FRAGMENT_NODE: Short
|
||||
public val NOTATION_NODE: Short
|
||||
public val DOCUMENT_POSITION_DISCONNECTED: Short
|
||||
public val DOCUMENT_POSITION_PRECEDING: Short
|
||||
public val DOCUMENT_POSITION_FOLLOWING: Short
|
||||
public val DOCUMENT_POSITION_CONTAINS: Short
|
||||
public val DOCUMENT_POSITION_CONTAINED_BY: Short
|
||||
public val DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: Short
|
||||
public val attributes: NamedNodeMap
|
||||
public val baseURI: String
|
||||
public val childNodes: NodeList
|
||||
public val firstChild: Node
|
||||
public val lastChild: Node
|
||||
public val localName: String
|
||||
public val namespaceURI: String
|
||||
public val nextSibling: Node
|
||||
public val nodeName: String
|
||||
public val nodeType: Short
|
||||
public val nodeValue: String
|
||||
public val ownerDocument: Document
|
||||
public val parentNode: Node
|
||||
public val prefix: String
|
||||
public val previousSibling: Node
|
||||
public val textContent: String
|
||||
public fun normalize(): Unit = js.noImpl
|
||||
public fun isSupported(arg1: String, arg2: String): Boolean = js.noImpl
|
||||
public fun getUserData(arg1: String): Any = js.noImpl
|
||||
public fun setUserData(arg1: String, arg2: Any, arg3: UserDataHandler): Any = js.noImpl
|
||||
public fun getFeature(arg1: String, arg2: String): Any = js.noImpl
|
||||
public fun hasAttributes(): Boolean = js.noImpl
|
||||
public fun setPrefix(arg1: String): Unit = js.noImpl
|
||||
public fun removeChild(arg1: Node): Node = js.noImpl
|
||||
public fun replaceChild(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun insertBefore(arg1: Node, arg2: Node): Node = js.noImpl
|
||||
public fun setNodeValue(arg1: String): Unit = js.noImpl
|
||||
public fun appendChild(arg1: Node): Node = js.noImpl
|
||||
public fun hasChildNodes(): Boolean = js.noImpl
|
||||
public fun cloneNode(arg1: Boolean): Node = js.noImpl
|
||||
public fun compareDocumentPosition(arg1: Node): Short = js.noImpl
|
||||
public fun setTextContent(arg1: String): Unit = js.noImpl
|
||||
public fun isSameNode(arg1: Node): Boolean = js.noImpl
|
||||
public fun lookupPrefix(arg1: String): String = js.noImpl
|
||||
public fun isDefaultNamespace(arg1: String): Boolean = js.noImpl
|
||||
public fun lookupNamespaceURI(arg1: String): String = js.noImpl
|
||||
public fun isEqualNode(arg1: Node): Boolean = js.noImpl
|
||||
|
||||
class object {
|
||||
public val ELEMENT_NODE: Short = 1
|
||||
public val ATTRIBUTE_NODE: Short = 2
|
||||
public val TEXT_NODE: Short = 3
|
||||
public val CDATA_SECTION_NODE: Short = 4
|
||||
public val ENTITY_REFERENCE_NODE: Short = 5
|
||||
public val ENTITY_NODE: Short = 6
|
||||
public val PROCESSING_INSTRUCTION_NODE: Short = 7
|
||||
public val COMMENT_NODE: Short = 8
|
||||
public val DOCUMENT_NODE: Short = 9
|
||||
public val DOCUMENT_TYPE_NODE: Short = 10
|
||||
public val DOCUMENT_FRAGMENT_NODE: Short = 11
|
||||
public val NOTATION_NODE: Short = 12
|
||||
public val DOCUMENT_POSITION_DISCONNECTED: Short = 1
|
||||
public val DOCUMENT_POSITION_PRECEDING: Short = 2
|
||||
public val DOCUMENT_POSITION_FOLLOWING: Short = 4
|
||||
public val DOCUMENT_POSITION_CONTAINS: Short = 8
|
||||
public val DOCUMENT_POSITION_CONTAINED_BY: Short = 16
|
||||
public val DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: Short = 32
|
||||
}
|
||||
}
|
||||
|
||||
native public trait NodeList {
|
||||
fun getLength(): Int = js.noImpl
|
||||
fun item(arg1: Int): Node = js.noImpl
|
||||
public val length: Int
|
||||
public fun item(arg1: Int): Node = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Notation: Node {
|
||||
fun getPublicId(): String = js.noImpl
|
||||
fun getSystemId(): String = js.noImpl
|
||||
public val publicId: String
|
||||
public val systemId: String
|
||||
}
|
||||
|
||||
native public trait ProcessingInstruction: Node {
|
||||
fun getData(): String = js.noImpl
|
||||
fun getTarget(): String = js.noImpl
|
||||
fun setData(arg1: String): Unit = js.noImpl
|
||||
public val data: String
|
||||
public val target: String
|
||||
public fun setData(arg1: String): Unit = js.noImpl
|
||||
}
|
||||
|
||||
native public trait Text: CharacterData {
|
||||
fun splitText(arg1: Int): Text = js.noImpl
|
||||
fun isElementContentWhitespace(): Boolean = js.noImpl
|
||||
fun getWholeText(): String = js.noImpl
|
||||
fun replaceWholeText(arg1: String): Text = js.noImpl
|
||||
public val wholeText: String
|
||||
public fun splitText(arg1: Int): Text = js.noImpl
|
||||
public fun isElementContentWhitespace(): Boolean = js.noImpl
|
||||
public fun replaceWholeText(arg1: String): Text = js.noImpl
|
||||
}
|
||||
|
||||
native public trait TypeInfo {
|
||||
fun getTypeName(): String = js.noImpl
|
||||
fun getTypeNamespace(): String = js.noImpl
|
||||
fun isDerivedFrom(arg1: String, arg2: String, arg3: Int): Boolean = js.noImpl
|
||||
public val DERIVATION_RESTRICTION: Int
|
||||
public val DERIVATION_EXTENSION: Int
|
||||
public val DERIVATION_UNION: Int
|
||||
public val DERIVATION_LIST: Int
|
||||
public val typeName: String
|
||||
public val typeNamespace: String
|
||||
public fun isDerivedFrom(arg1: String, arg2: String, arg3: Int): Boolean = js.noImpl
|
||||
|
||||
class object {
|
||||
public val DERIVATION_RESTRICTION: Int = 1
|
||||
public val DERIVATION_EXTENSION: Int = 2
|
||||
public val DERIVATION_UNION: Int = 4
|
||||
public val DERIVATION_LIST: Int = 8
|
||||
}
|
||||
}
|
||||
|
||||
native public trait UserDataHandler {
|
||||
fun handle(arg1: Short, arg2: String, arg3: Any, arg4: Node, arg5: Node): Unit = js.noImpl
|
||||
public val NODE_CLONED: Short
|
||||
public val NODE_IMPORTED: Short
|
||||
public val NODE_DELETED: Short
|
||||
public val NODE_RENAMED: Short
|
||||
public val NODE_ADOPTED: Short
|
||||
public fun handle(arg1: Short, arg2: String, arg3: Any, arg4: Node, arg5: Node): Unit = js.noImpl
|
||||
|
||||
class object {
|
||||
public val NODE_CLONED: Short = 1
|
||||
public val NODE_IMPORTED: Short = 2
|
||||
public val NODE_DELETED: Short = 3
|
||||
public val NODE_RENAMED: Short = 4
|
||||
public val NODE_ADOPTED: Short = 5
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,23 +11,20 @@ import java.lang.IndexOutOfBoundsException
|
||||
|
||||
// Properties
|
||||
|
||||
val Document?.rootElement : Element?
|
||||
get() = if (this != null) this.getDocumentElement() else null
|
||||
|
||||
|
||||
var Node.text : String
|
||||
get() {
|
||||
if (this.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (this.nodeType == Node.ELEMENT_NODE) {
|
||||
val buffer = StringBuilder()
|
||||
val nodeList = this.getChildNodes()
|
||||
val nodeList = this.childNodes
|
||||
if (nodeList != null) {
|
||||
var i = 0
|
||||
val size = nodeList.getLength()
|
||||
val size = nodeList.length
|
||||
while (i < size) {
|
||||
val node = nodeList.item(i)
|
||||
if (node != null) {
|
||||
if (node.isText()) {
|
||||
buffer.append(node.getNodeValue())
|
||||
buffer.append(node.nodeValue)
|
||||
}
|
||||
}
|
||||
i++
|
||||
@@ -35,11 +32,11 @@ get() {
|
||||
}
|
||||
return buffer.toString().sure()
|
||||
} else {
|
||||
return this.getNodeValue() ?: ""
|
||||
return this.nodeValue
|
||||
}
|
||||
}
|
||||
set(value) {
|
||||
if (this.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (this.nodeType == Node.ELEMENT_NODE) {
|
||||
val element = this as Element
|
||||
// lets remove all the previous text nodes first
|
||||
for (node in element.children()) {
|
||||
@@ -74,7 +71,7 @@ set(value) {
|
||||
|
||||
/** Returns the children of the element as a list */
|
||||
inline fun Element?.children(): List<Node> {
|
||||
return this?.getChildNodes().toList()
|
||||
return this?.childNodes.toList()
|
||||
}
|
||||
|
||||
/** The child elements of this document */
|
||||
@@ -175,7 +172,7 @@ class NodeListAsList(val nodeList: NodeList): AbstractList<Node>() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun size(): Int = nodeList.getLength()
|
||||
override fun size(): Int = nodeList.length
|
||||
}
|
||||
|
||||
class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
|
||||
@@ -183,14 +180,14 @@ class ElementListAsList(val nodeList: NodeList): AbstractList<Element>() {
|
||||
val node = nodeList.item(index)
|
||||
if (node == null) {
|
||||
throw IndexOutOfBoundsException("NodeList does not contain a node at index: " + index)
|
||||
} else if (node.getNodeType() == Node.ELEMENT_NODE) {
|
||||
} else if (node.nodeType == Node.ELEMENT_NODE) {
|
||||
return node as Element
|
||||
} else {
|
||||
throw IllegalArgumentException("Node is not an Element as expected but is $node")
|
||||
}
|
||||
}
|
||||
|
||||
override fun size(): Int = nodeList.getLength()
|
||||
override fun size(): Int = nodeList.length
|
||||
|
||||
}
|
||||
|
||||
@@ -202,7 +199,7 @@ fun Node.nextSiblings() : Iterator<Node> = NextSiblingIterator(this)
|
||||
class NextSiblingIterator(var node: Node) : AbstractIterator<Node>() {
|
||||
|
||||
override fun computeNext(): Unit {
|
||||
val nextValue = node.getNextSibling()
|
||||
val nextValue = node.nextSibling
|
||||
if (nextValue != null) {
|
||||
setNext(nextValue)
|
||||
node = nextValue
|
||||
@@ -218,7 +215,7 @@ fun Node.previousSiblings() : Iterator<Node> = PreviousSiblingIterator(this)
|
||||
class PreviousSiblingIterator(var node: Node) : AbstractIterator<Node>() {
|
||||
|
||||
override fun computeNext(): Unit {
|
||||
val nextValue = node.getPreviousSibling()
|
||||
val nextValue = node.previousSibling
|
||||
if (nextValue != null) {
|
||||
setNext(nextValue)
|
||||
node = nextValue
|
||||
@@ -230,8 +227,8 @@ class PreviousSiblingIterator(var node: Node) : AbstractIterator<Node>() {
|
||||
|
||||
/** Returns true if this node is a Text node or a CDATA node */
|
||||
fun Node.isText(): Boolean {
|
||||
val nodeType = getNodeType()
|
||||
return nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE
|
||||
val nt = nodeType
|
||||
return nt == Node.TEXT_NODE || nt == Node.CDATA_SECTION_NODE
|
||||
}
|
||||
|
||||
/** Returns the attribute value or empty string if its not present */
|
||||
@@ -240,7 +237,7 @@ inline fun Element.attribute(name: String): String {
|
||||
}
|
||||
|
||||
val NodeList?.head : Node?
|
||||
get() = if (this != null && this.getLength() > 0) this.item(0) else null
|
||||
get() = if (this != null && this.length > 0) this.item(0) else null
|
||||
|
||||
val NodeList?.first : Node?
|
||||
get() = this.head
|
||||
@@ -250,7 +247,7 @@ get() {
|
||||
if (this == null) {
|
||||
return null
|
||||
} else {
|
||||
val s = this.getLength()
|
||||
val s = this.length
|
||||
return if (s > 0) this.item(s - 1) else null
|
||||
}
|
||||
}
|
||||
@@ -295,8 +292,8 @@ fun Element.createElement(name: String, doc: Document? = null, init: Element.()-
|
||||
|
||||
/** Returns the owner document of the element or uses the provided document */
|
||||
fun Node.ownerDocument(doc: Document? = null): Document {
|
||||
val answer = if (this != null && this.getNodeType() == Node.DOCUMENT_NODE) this as Document
|
||||
else if (doc == null) this.getOwnerDocument()
|
||||
val answer = if (this != null && this.nodeType == Node.DOCUMENT_NODE) this as Document
|
||||
else if (doc == null) this.ownerDocument
|
||||
else doc
|
||||
|
||||
if (answer == null) {
|
||||
|
||||
@@ -19,6 +19,79 @@ import javax.xml.transform.stream.StreamResult
|
||||
import org.w3c.dom.*
|
||||
import org.xml.sax.InputSource
|
||||
|
||||
val Node.nodeName: String
|
||||
get() = getNodeName() ?: ""
|
||||
|
||||
val Node.nodeValue: String
|
||||
get() = getNodeValue() ?: ""
|
||||
|
||||
val Node.nodeType: Short
|
||||
get() = getNodeType()
|
||||
|
||||
val Node.parentNode: Node?
|
||||
get() = getParentNode()
|
||||
|
||||
val Node.childNodes: NodeList
|
||||
get() = getChildNodes()!!
|
||||
|
||||
val Node.firstChild: Node?
|
||||
get() = getFirstChild()
|
||||
|
||||
val Node.lastChild: Node?
|
||||
get() = getLastChild()
|
||||
|
||||
val Node.nextSibling: Node?
|
||||
get() = getNextSibling()
|
||||
|
||||
val Node.previousSibling: Node?
|
||||
get() = getPreviousSibling()
|
||||
|
||||
val Node.attributes: NamedNodeMap?
|
||||
get() = getAttributes()
|
||||
|
||||
val Node.ownerDocument: Document?
|
||||
get() = getOwnerDocument()
|
||||
|
||||
val Document.documentElement: Element?
|
||||
get() = if (this != null) this.getDocumentElement() else null
|
||||
|
||||
val Node.namespaceURI: String
|
||||
get() = getNamespaceURI() ?: ""
|
||||
|
||||
val Node.prefix: String
|
||||
get() = getPrefix() ?: ""
|
||||
|
||||
val Node.localName: String
|
||||
get() = getLocalName() ?: ""
|
||||
|
||||
val Node.baseURI: String
|
||||
get() = getBaseURI() ?: ""
|
||||
|
||||
var Node.textContent: String
|
||||
get() = getTextContent() ?: ""
|
||||
set(value) {
|
||||
setTextContent(value)
|
||||
}
|
||||
|
||||
val DOMStringList.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
val NameList.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
val DOMImplementationList.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
val NodeList.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
val CharacterData.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
val NamedNodeMap.length: Int
|
||||
get() = this.getLength()
|
||||
|
||||
|
||||
/** Returns an [[Iterator]] of all the next [[Element]] siblings */
|
||||
fun Node.nextElements(): Iterator<Element> = nextSiblings().filterIsInstance<Node, Element>(javaClass<Element>())
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class DomBuilderTest() : TestCase() {
|
||||
assertEquals(1, doc["#id2"].size())
|
||||
assertEquals(1, doc["#id3"].size())
|
||||
|
||||
val root = doc.rootElement
|
||||
val root = doc.documentElement
|
||||
if (root == null) {
|
||||
fail("No root!")
|
||||
} else {
|
||||
@@ -120,7 +120,7 @@ class DomBuilderTest() : TestCase() {
|
||||
} else {
|
||||
fail("Not an Element $grandChild")
|
||||
}
|
||||
val children = doc.rootElement.children()
|
||||
val children = doc.documentElement.children()
|
||||
val xml = nodesToXmlString(children)
|
||||
println("root element has children: ${xml}")
|
||||
assertEquals(1, children.size())
|
||||
|
||||
@@ -3,8 +3,11 @@ package org.jetbrains.kotlin.tools
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.io.PrintWriter
|
||||
import org.w3c.dom.*
|
||||
import java.lang.reflect.Method
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.ArrayList
|
||||
import java.util.TreeMap
|
||||
import org.w3c.dom.*
|
||||
|
||||
/**
|
||||
* This tool generates JavaScript stubs for classes available in the JDK which are already available in the browser environment
|
||||
@@ -29,10 +32,10 @@ import js.noImpl
|
||||
|
||||
val classes = arrayList(javaClass<Attr>(), javaClass<CDATASection>(),
|
||||
javaClass<CharacterData>(), javaClass<Comment>(),
|
||||
javaClass<Document>(),javaClass<DocumentFragment>(),javaClass<DocumentType>(),
|
||||
javaClass<Document>(), javaClass<DocumentFragment>(), javaClass<DocumentType>(),
|
||||
javaClass<DOMConfiguration>(),
|
||||
javaClass<DOMError>(), javaClass<DOMErrorHandler>(),
|
||||
javaClass<DOMImplementation>(),
|
||||
javaClass<DOMImplementation>(), javaClass<DOMImplementationList>(),
|
||||
javaClass<DOMLocator>(),
|
||||
javaClass<DOMStringList>(),
|
||||
javaClass<Element>(),
|
||||
@@ -53,31 +56,78 @@ import js.noImpl
|
||||
|
||||
println("native public trait ${klass.getSimpleName()}$extends {")
|
||||
|
||||
// lets iterate through each method
|
||||
val methods = klass.getDeclaredMethods()
|
||||
if (methods != null) {
|
||||
// lets figure out the properties versus methods
|
||||
val validMethods = ArrayList<Method>()
|
||||
val properties = TreeMap<String, String>()
|
||||
for (method in methods) {
|
||||
if (method != null) {
|
||||
val parameterTypes = method.getParameterTypes()!!
|
||||
val name = method.getName() ?: ""
|
||||
fun propertyName(): String {
|
||||
val answer = name.substring(3).decapitalize()
|
||||
return if (answer == "type") {
|
||||
"`type`"
|
||||
} else answer
|
||||
}
|
||||
fun propertyType() = simpleTypeName(method.getReturnType())
|
||||
|
||||
// TODO in java 7 its not easy with reflection to get the parameter argument name...
|
||||
var counter = 0
|
||||
val parameters = parameterTypes.map<Class<out Any?>?, String>{ "arg${++counter}: ${simpleTypeName(it)}" }.makeString(", ")
|
||||
val returnType = simpleTypeName(method.getReturnType())
|
||||
println(" fun ${method.getName()}($parameters): $returnType = js.noImpl")
|
||||
val params = method.getParameterTypes()
|
||||
val paramSize = params?.size ?: 0
|
||||
if (name.size > 3) {
|
||||
if (name.startsWith("get") && paramSize == 0) {
|
||||
val propName = propertyName()
|
||||
if (!properties.containsKey(propName)) {
|
||||
properties.put(propName, "public val $propName: ${propertyType()}")
|
||||
}
|
||||
} else if (name.startsWith("set") && paramSize == 0) {
|
||||
val propName = propertyName()
|
||||
properties.put(propName, "public var $propName: ${propertyType()}")
|
||||
} else {
|
||||
validMethods.add(method)
|
||||
}
|
||||
} else {
|
||||
validMethods.add(method)
|
||||
}
|
||||
}
|
||||
}
|
||||
for (statement in properties.values()) {
|
||||
println(" $statement")
|
||||
}
|
||||
for (method in validMethods) {
|
||||
val parameterTypes = method.getParameterTypes()!!
|
||||
|
||||
// TODO in java 7 its not easy with reflection to get the parameter argument name...
|
||||
var counter = 0
|
||||
val parameters = parameterTypes.map<Class<out Any?>?, String>{ "arg${++counter}: ${simpleTypeName(it)}" }.makeString(", ")
|
||||
val returnType = simpleTypeName(method.getReturnType())
|
||||
println(" public fun ${method.getName()}($parameters): $returnType = js.noImpl")
|
||||
}
|
||||
}
|
||||
val fields = klass.getDeclaredFields()
|
||||
if (fields != null) {
|
||||
for (field in fields) {
|
||||
if (field != null) {
|
||||
val modifiers = field.getModifiers()
|
||||
if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
|
||||
val fieldType = simpleTypeName(field.getType())
|
||||
println(" public val ${field.getName()}: $fieldType")
|
||||
if (fields.notEmpty()) {
|
||||
println("")
|
||||
println(" class object {")
|
||||
for (field in fields) {
|
||||
if (field != null) {
|
||||
val modifiers = field.getModifiers()
|
||||
if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) {
|
||||
val fieldType = simpleTypeName(field.getType())
|
||||
try {
|
||||
val value = field.get(null)
|
||||
if (value != null) {
|
||||
val fieldType = simpleTypeName(field.getType())
|
||||
println(" public val ${field.getName()}: $fieldType = $value")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
println("Caught: $e")
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
println(" }")
|
||||
}
|
||||
}
|
||||
println("}")
|
||||
|
||||
Reference in New Issue
Block a user