Up to Main Index Up to Journal for September, 2013
JOURNAL FOR MONDAY 16TH SEPTEMBER, 2013
______________________________________________________________________________
SUBJECT: Yet more progress with the loader
DATE: Mon 16 Sep 22:07:32 BST 2013
In an unexpected turn of events I've made even more progress with the loader.
I've been cleaning up the hacky code and it's gone quite well. I dropped
nearly all of the ugly conversions I had and simplified a lot of the
functions. For example:
func (_ *Mobile) Unmarshal(r recordjar.Record) recordjar.Unmarshaler {
m := &Mobile{}
m.Thing = *(m.Thing.Unmarshal(r).(*thing.Thing))
return m
}
Is now just:
func (m *Mobile) Unmarshal(r recordjar.Record) {
m.Thing.Unmarshal(r)
}
The only bookkeeping you need to do is register the types you want to be able
to Marshal/Unmarshal:
func init() {
loader.Register("mobile", &Mobile{})
}
Besides writing type specific init, Init (post Unmarshal) and Unmarshal it's
all turning out quite easy...
--
Diddymus
Up to Main Index Up to Journal for September, 2013