progress. still not working. this is incredibly difficult.

This commit is contained in:
Andrew Gallant (Ocelot)
2012-04-29 03:38:29 -04:00
parent 52a21b415a
commit 6bf0191fb0
10 changed files with 385 additions and 80 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/xml"
"fmt"
"log"
"strings"
)
type Context struct {
@@ -33,31 +32,6 @@ func (c *Context) Put(format string, v ...interface{}) {
}
}
// TypePrefix searches the parsed XML for a type matching 'needle'.
// It then returns the appropriate prefix to be used in source code.
// Note that the core X protocol *is* a namespace, but does not have a prefix.
// Also note that you should probably check the BaseTypeMap and TypeMap
// before calling this function.
func (c *Context) TypePrefix(needle Type) string {
// If this is xproto, quit. No prefixes needed.
if c.xml.Header == "xproto" {
return ""
}
// First check for the type in the current namespace.
if c.xml.HasType(needle) {
return strings.Title(c.xml.Header)
}
// Now check each of the imports...
for _, imp := range c.xml.Imports {
if imp.xml.Header != "xproto" && imp.xml.HasType(needle) {
return strings.Title(imp.xml.Header)
}
}
return ""
}
// Translate is the big daddy of them all. It takes in an XML byte slice
// and writes Go code to the 'out' buffer.
@@ -76,14 +50,4 @@ func (c *Context) Translate(xmlBytes []byte) {
// It's Morphin' Time!
c.xml.Morph(c)
// for _, req := range c.xml.Requests {
// if req.Name != "CreateContext" && req.Name != "MakeCurrent" {
// continue
// }
// log.Println(req.Name)
// for _, field := range req.Fields {
// log.Println("\t", field.XMLName.Local, field.Type.Morph(c))
// }
// }
}