[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Standalone IDL has FloatArray where it probably means Float32Array



On 4/3/12 6:43 PM, Kenneth Russell wrote:
Cool, thanks; that's remarkably simple.

This whole web thing... when it works, it's really nice. ;)

There's currently no generation script associated with the spec or
webgl.idl. If you'd be willing to write the Python to produce
webgl.idl from the spec, I'll write the Makefile to hook it up.

Attached. You'll need to have the html5lib Python module installed, but hopefully that's not too big a problem. If we do need something that doesn't use html5lib, please count me out; the chances of screwing it up somehow are too high. ;)


-Boris
import sys
import html5lib

htmlfilename = sys.argv[1]
htmlfile = open(htmlfilename)
try:
    doc = html5lib.parse(htmlfile, treebuilder="dom")
finally:
    htmlfile.close()

def elementHasClass(el, classArg):
    """
    Return true if and only if classArg is one of the classes of el
    """
    classes = [ c for c in el.getAttribute("class").split(" ") if c is not "" ]
    return classArg in classes

def elementTextContent(el):
    """
    Implementation of DOM Core's .textContent
    """
    textContent = ""
    for child in el.childNodes:
        if child.nodeType == 3: # Node.TEXT_NODE
            textContent += child.data
        elif child.nodeType == 1: # Node.ELEMENT_NODE
            textContent += elementTextContent(child)
        else:
            # Other nodes are ignored
            pass
    return textContent

preList = doc.getElementsByTagName("pre")
idlList = [elementTextContent(p) for p in preList if elementHasClass(p, "idl") ]
print "\n\n".join(idlList)