Hey,

Well I am a gluten for punishment but, I love parsers and translations so
without further ado;

>From this source file;

https://github.com/google/closure-compiler/blob/master/externs/w3c_dom1.js

I am creating the following ActionScript, long but worth looking at. :)

I found a lot of extern files, so this is how we do it in the start. We
could even defined externs ourselves, the benefit is, one file of a bunch
of javascript classes translates into a bunch of ActionScript files.

This is grabbing docs and analyzing types. More to test but I am using the
Rhino parser and AST, made my own walker and wrote the logic to assemble
class, field and method definitions while the root AST is walked.

So now, if you want a creatjs API, just follow GCC extern file template and
you will have it.

Mike

--------------------------------------------------------------------
ActionScript output, will be individual files
--------------------------------------------------------------------



package dom {

public Document extends Node {

    native public function Document();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-implementation
     */
    native public var implementation:DOMImplementation;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-doctype
     */
    native public var doctype:DocumentType;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-documentElement
     */
    native public var documentElement:Element;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createComment
     */
    native public function createComment(data:String):Comment;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-A6C9094
     */
    native public function getElementsByTagName(tagname:String):NodeList;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createEntityReference
     */
    native public function
createEntityReference(name:String):EntityReference;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createAttribute
     */
    native public function createAttribute(name:String):Attr;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createTextNode
     */
    native public function createTextNode(data:Object):Text;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createCDATASection
     */
    native public function createCDATASection(data:String):CDATASection;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createProcessingInstruction
     */
    native public function createProcessingInstruction(target:String,
data:String):ProcessingInstruction;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createElement
     * @see
http://w3c.github.io/webcomponents/spec/custom/#extensions-to-document-interface-to-instantiate
     */
    native public function createElement(tagName:String,
opt_typeExtension:String = null):Element;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-createDocumentFragment
     */
    native public function createDocumentFragment():DocumentFragment;

}
}

package dom {

public CharacterData extends Node {

    native public function CharacterData();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-7D61178C
     */
    native public var length:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-72AB8359
     */
    native public var data:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-E5CBA7FB
     */
    native public function replaceData(offset:Number, count:Number,
arg:Number):void;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-7C603781
     */
    native public function deleteData(offset:Number, count:Number):void;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-6531BCCF
     */
    native public function substringData(offset:Number,
count:Number):String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-3EDB695F
     */
    native public function insertData(offset:Number, arg:Number):void;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-32791A2F
     */
    native public function appendData(arg:String):void;

}
}

package dom {

public DocumentFragment extends Node {

    native public function DocumentFragment();

}
}

package dom {

public Attr extends Node {

    native public function Attr();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-862529273
     */
    native public var specified:Boolean;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1112119403
     */
    native public var name:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-221662474
     */
    native public var value:String;

}
}

package dom {

public Comment extends CharacterData {

    native public function Comment();

}
}

package dom {

public Notation extends Node {

    native public function Notation();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-54F2B4D0
     */
    native public var publicId:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-E8AAB1D0
     */
    native public var systemId:String;

}
}

package dom {

public NamedNodeMap {

    native public function NamedNodeMap();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-6D0FB19E
     */
    native public var length:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1074577549
     */
    native public function getNamedItem(name:String):Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-349467F9
     */
    native public function item(index:Number):Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1025163788
     */
    native public function setNamedItem(arg:Node):Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D58B193
     */
    native public function removeNamedItem(name:String):Node;

}
}

package dom {

public CDATASection extends Text {

    native public function CDATASection();

}
}

package dom {

public Text extends CharacterData {

    native public function Text();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-38853C1D
     */
    native public function splitText(offset:Number):Text;

}
}

package dom {

public Node implements EventTarget {

    native public function Node();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var TEXT_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var ENTITY_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var DOCUMENT_TYPE_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var NOTATION_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var CDATA_SECTION_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var DOCUMENT_FRAGMENT_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var COMMENT_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var PROCESSING_INSTRUCTION_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var XPATH_NAMESPACE_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var ELEMENT_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var ENTITY_REFERENCE_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var ATTRIBUTE_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1950641247
     */
    native public static var DOCUMENT_NODE:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-previousSibling
     */
    native public var previousSibling:Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-parentNode
     */
    native public var parentNode:Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-nodeValue
     */
    native public var nodeValue:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-nodeName
     */
    native public var nodeName:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-firstChild
     */
    native public var firstChild:Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-childNodes
     */
    native public var childNodes:NodeList;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-attributes
     */
    native public var attributes:NamedNodeMap;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-nodeType
     */
    native public var nodeType:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-ownerDocument
     */
    native public var ownerDocument:Document;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-nextSibling
     */
    native public var nextSibling:Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-lastChild
     */
    native public var lastChild:Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-removeChild
     */
    native public function removeChild(oldChild:Node):Node;

    /**
     */
    native public override function addEventListener(type:Boolean,
listener:Boolean, opt_useCapture:Boolean = null):Object;

    /**
     */
    native public override function dispatchEvent(evt:Object):Object;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-insertBefore
     */
    native public function insertBefore(newChild:Node, refChild:Node):Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-hasChildNodes
     */
    native public function hasChildNodes():Boolean;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-appendChild
     */
    native public function appendChild(newChild:Node):Node;

    /**
     */
    native public override function removeEventListener(type:Boolean,
listener:Boolean, opt_useCapture:Boolean = null):Object;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-replaceChild
     */
    native public function replaceChild(newChild:Node, oldChild:Node):Node;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-cloneNode
     */
    native public function cloneNode(deep:Boolean):Node;

}
}

package dom {

public DOMException {

    native public function DOMException();

}
}

package dom {

public DOMImplementation {

    native public function DOMImplementation();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-5CED94D7
     */
    native public function hasFeature(feature:String,
version:String):Boolean;

}
}

package dom {

public ProcessingInstruction extends Node {

    native public function ProcessingInstruction();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1478689192
     */
    native public var target:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-837822393
     */
    native public var data:String;

}
}

package dom {

public DocumentType extends Node {

    native public function DocumentType();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D46829EF
     */
    native public var notations:NamedNodeMap;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1844763134
     */
    native public var name:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1788794630
     */
    native public var entities:NamedNodeMap;

}
}

package dom {

public ExceptionCode {

    native public function ExceptionCode();

}
}

package dom {

public Window implements EventTarget {

    native public function Window();

    /**
     */
    native public var onmousewheel:Function;

    /**
     */
    native public var onunload:Function;

    /**
     */
    native public var onerror:Function;

    /**
     */
    native public var onhashchange:Function;

    /**
     */
    native public var onpopstate:Function;

    /**
     */
    native public var onresize:Function;

    /**
     */
    native public var onblur:Function;

    /**
     */
    native public var onmouseup:Function;

    /**
     */
    native public var onpaint:Function;

    /**
     */
    native public var onclose:Function;

    /**
     */
    native public var Window:Object;

    /**
     */
    native public var onbeforeunload:Function;

    /**
     */
    native public var onmousemove:Function;

    /**
     */
    native public var oncontextmenu:Function;

    /**
     */
    native public var ondblclick:Function;

    /**
     */
    native public var onmouseout:Function;

    /**
     */
    native public var onkeyup:Function;

    /**
     */
    native public var onfocus:Function;

    /**
     */
    native public var onkeydown:Function;

    /**
     */
    native public var onkeypress:Function;

    /**
     */
    native public var onsubmit:Function;

    /**
     */
    native public var onchange:Function;

    /**
     */
    native public var onabort:Function;

    /**
     */
    native public var onreset:Function;

    /**
     */
    native public var onmouseover:Function;

    /**
     */
    native public var onselect:Function;

    /**
     */
    native public var onload:Function;

    /**
     */
    native public var onwheel:Function;

    /**
     */
    native public var onscroll:Function;

    /**
     */
    native public var onclick:Function;

    /**
     */
    native public var ondragdrop:Function;

    /**
     */
    native public var onmousedown:Function;

    /**
     */
    native public override function addEventListener(type:Boolean,
listener:Boolean, opt_useCapture:Boolean = null):Object;

    /**
     */
    native public override function dispatchEvent(evt:Object):Object;

    /**
     */
    native public override function removeEventListener(type:Boolean,
listener:Boolean, opt_useCapture:Boolean = null):Object;

}
}

package dom {

public EntityReference extends Node {

    native public function EntityReference();

}
}

package dom {

public NodeList {

    native public function NodeList();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-203510337
     */
    native public var length:Number;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-844377136
     */
    native public function item(index:Number):Node;

}
}

package dom {

public Element extends Node {

    native public function Element();

    /**
     */
    native public var onmousewheel:Function;

    /**
     */
    native public var oncompositionstart:Function;

    /**
     */
    native public var onunload:Function;

    /**
     */
    native public var onerror:Function;

    /**
     */
    native public var onresize:Function;

    /**
     */
    native public var onmouseup:Function;

    /**
     */
    native public var onblur:Function;

    /**
     */
    native public var onbeforeinput:Function;

    /**
     */
    native public var onmousemove:Function;

    /**
     */
    native public var onbeforeunload:Function;

    /**
     */
    native public var oncontextmenu:Function;

    /**
     */
    native public var onfocusout:Function;

    /**
     */
    native public var ondblclick:Function;

    /**
     */
    native public var onmouseout:Function;

    /**
     */
    native public var onkeyup:Function;

    /**
     */
    native public var oncompositionend:Function;

    /**
     */
    native public var onfocus:Function;

    /**
     */
    native public var onkeydown:Function;

    /**
     */
    native public var onkeypress:Function;

    /**
     */
    native public var onsubmit:Function;

    /**
     */
    native public var onchange:Function;

    /**
     */
    native public var onabort:Function;

    /**
     */
    native public var onreset:Function;

    /**
     */
    native public var onmouseover:Function;

    /**
     */
    native public var oninput:Function;

    /**
     */
    native public var oncompositionupdate:Function;

    /**
     */
    native public var onselect:Function;

    /**
     */
    native public var oncut:Function;

    /**
     */
    native public var ontextinput:Function;

    /**
     */
    native public var onload:Function;

    /**
     */
    native public var onwheel:Function;

    /**
     */
    native public var onpaste:Function;

    /**
     */
    native public var onscroll:Function;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#attribute-tagName
     */
    native public var tagName:String;

    /**
     */
    native public var onclick:Function;

    /**
     */
    native public var onmousedown:Function;

    /**
     */
    native public var oncopy:Function;

    /**
     */
    native public var onfocusin:Function;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-removeAttributeNode
     */
    native public function removeAttributeNode(oldAttr:Attr):Attr;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-1938918D
     */
    native public function getElementsByTagName(tagname:String):NodeList;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-getAttributeNode
     */
    native public function getAttributeNode(name:String):Attr;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-setAttributeNode
     */
    native public function setAttributeNode(newAttr:Attr):Attr;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-removeAttribute
     */
    native public function removeAttribute(name:String):void;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-setAttribute
     */
    native public function setAttribute(name:String, value:String):void;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#method-getAttribute
     * @see http://msdn.microsoft.com/en-us/library/ms536429(VS.85).aspx
     */
    native public function getAttribute(name:String, opt_flags:String =
null):String;

}
}

package dom {

public Entity extends Node {

    native public function Entity();

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D7303025
     */
    native public var publicId:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-D7C29F3E
     */
    native public var systemId:String;

    /**
     * @see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core.html#ID-6ABAEB38
     */
    native public var notationName:String;

}
}

Reply via email to