progress. still not working. this is incredibly difficult.
This commit is contained in:
@@ -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))
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user