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

@@ -87,9 +87,15 @@ func newCookie(id uint16) *Cookie {
}
}
// Event is an interface that can contain any of the events returned by the server.
// Use a type assertion switch to extract the Event structs.
type Event interface{}
// Event is an interface that can contain any of the events returned by the
// server. Use a type assertion switch to extract the Event structs.
type Event interface {
ImplementsEvent()
}
// newEventFuncs is a map from event numbers to functions that create
// the corresponding event.
var newEventFuncs map[int]func(buf []byte) Event
// Error contains protocol errors returned to us by the X server.
type Error struct {
@@ -100,6 +106,16 @@ type Error struct {
Id Id
}
// Error2 is an interface that can contain any of the errors returned by
// the server. Use a type assertion switch to extract the Error structs.
type Error2 interface {
ImplementsError()
}
// newErrorFuncs is a map from error numbers to functions that create
// the corresponding error.
var newErrorFuncs map[int]func(buf []byte) Error2
func (e *Error) Error() string {
return fmt.Sprintf("Bad%s (major=%d minor=%d cookie=%d id=0x%x)",
errorNames[e.Detail], e.Major, e.Minor, e.Cookie, e.Id)