Changed the cSysData dummy functions to an interface that a dummy sysData instance is tested against to make sure that not only all functions exist, but also that they are all the correct type.

This commit is contained in:
Pietro Gagliardi 2014-04-01 15:34:51 -04:00
parent 593ded848b
commit dbbabf35c3
1 changed files with 23 additions and 61 deletions

View File

@ -2,10 +2,6 @@
package ui
import (
"runtime"
)
const eventbufsiz = 100 // suggested by skelterjohn
// newEvent returns a new channel suitable for listening for events.
@ -22,63 +18,29 @@ type cSysData struct {
alternate bool // editable for Combobox, multi-select for listbox, password for lineedit
handler AreaHandler // for Areas
}
func (c *cSysData) make(initText string, window *sysData) error {
panic(runtime.GOOS + " sysData does not define make()")
}
func (c *cSysData) firstShow() error {
panic(runtime.GOOS + " sysData does not define firstShow()")
}
func (c *cSysData) show() {
panic(runtime.GOOS + " sysData does not define show()")
}
func (c *cSysData) hide() {
panic(runtime.GOOS + " sysData does not define hide()")
}
func (c *cSysData) setText(text string) {
panic(runtime.GOOS + " sysData does not define setText()")
}
func (c *cSysData) setRect(x int, y int, width int, height int, winheight int) error {
panic(runtime.GOOS + " sysData does not define setRect()")
}
func (c *cSysData) isChecked() bool {
panic(runtime.GOOS + " sysData does not define isChecked()")
}
func (c *cSysData) text() string {
panic(runtime.GOOS + " sysData does not define text()")
}
func (c *cSysData) append(string) {
panic(runtime.GOOS + " sysData does not define append()")
}
func (c *cSysData) insertBefore(string, int) {
panic(runtime.GOOS + " sysData does not define insertBefore()")
}
func (c *cSysData) selectedIndex() int {
panic(runtime.GOOS + " sysData does not define selectedIndex()")
}
func (c *cSysData) selectedIndices() []int {
panic(runtime.GOOS + " sysData does not define selectedIndices()")
}
func (c *cSysData) selectedTexts() []string {
panic(runtime.GOOS + " sysData does not define selectedIndex()")
}
func (c *cSysData) setWindowSize(int, int) error {
panic(runtime.GOOS + " sysData does not define setWindowSize()")
}
func (c *cSysData) delete(int) {
panic(runtime.GOOS + " sysData does not define delete()")
}
func (c *cSysData) preferredSize() (int, int) {
panic(runtime.GOOS + " sysData does not define preferredSize()")
}
func (c *cSysData) setProgress(int) {
panic(runtime.GOOS + " sysData does not define setProgress()")
}
func (c *cSysData) len() int {
panic(runtime.GOOS + " sysData does not define len()")
}
func (c *cSysData) setAreaSize(int, int) {
panic(runtime.GOOS + " sysData does not define setAreaSize()")
}
// this interface is used to make sure all sysDatas are synced
var _xSysData interface {
make(initText string, window *sysData) error
firstShow() error
show()
hide()
setText(text string)
setRect(x int, y int, width int, height int, winheight int) error
isChecked() bool
text() string
append(string)
insertBefore(string, int)
selectedIndex() int
selectedIndices() []int
selectedTexts() []string
setWindowSize(int, int) error
delete(int)
preferredSize() (int, int)
setProgress(int)
len() int
setAreaSize(int, int)
} = &sysData{} // this line will error if there's an inconsistency
// signal sends the event signal. This raise is done asynchronously to avoid deadlocking the UI task.
// Thanks skelterjohn for this techinque: if we can't queue any more events, drop them