diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 10:35:52 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-09-12 10:35:52 -0600 |
commit | e8199ec88c7ca8107c4fb9238e383a4a9eb981ee (patch) | |
tree | 250c514c0cb4ec2b8bd442f4e80e916fb8ad6f2c /src/nslcd_proto/util | |
parent | f0302e1ac1a12711a9f49c3d7a62bcdfcaca7eed (diff) |
Derp, channels and goroutines are enumerators
Diffstat (limited to 'src/nslcd_proto/util')
-rw-r--r-- | src/nslcd_proto/util/enumerator@T.got | 45 | ||||
-rwxr-xr-x | src/nslcd_proto/util/struct_null_backend.go.sh | 2 |
2 files changed, 1 insertions, 46 deletions
diff --git a/src/nslcd_proto/util/enumerator@T.got b/src/nslcd_proto/util/enumerator@T.got deleted file mode 100644 index 5ce5cb5..0000000 --- a/src/nslcd_proto/util/enumerator@T.got +++ /dev/null @@ -1,45 +0,0 @@ -package util - -import "nslcd_proto" - -type <T>_List struct { - dat []nslcd_proto.<T> - i int -} - -var _ nslcd_proto.<T>_Enumerator = &<T>_List{} - -func New_<T>_List(ary []nslcd_proto.<T>) *<T>_List { - return &<T>_List{ary, 0} -} - -func (o *<T>_List) GetNext() (n *nslcd_proto.<T>, err error) { - if o.i < len(o.dat) { - n = &o.dat[o.i] - o.i++ - } - err = nil - return -} - -func (o *<T>_List) GenericGetNext() (n *interface{}, err error) { - a, err := o.GetNext() - if a != nil { - b := (interface{})(*a) - n = &b - } - return -} - -type <T>_Ø struct{} - -var _ nslcd_proto.<T>_Enumerator = <T>_Ø{} - -func (o <T>_Ø) GetNext() (*nslcd_proto.<T>, error) { - return nil, nil -} -func (o <T>_Ø) GenericGetNext() (*interface{}, error) { - return nil, nil -} - -// -*- Mode: Go -*- diff --git a/src/nslcd_proto/util/struct_null_backend.go.sh b/src/nslcd_proto/util/struct_null_backend.go.sh index 9d1c1b0..1714e9a 100755 --- a/src/nslcd_proto/util/struct_null_backend.go.sh +++ b/src/nslcd_proto/util/struct_null_backend.go.sh @@ -8,7 +8,7 @@ import p "nslcd_proto" type NullBackend struct{} -$(< "$interface" sed -rn 's/^\t([^(]+)\(Ucred, ([^)]+)\) (\S+)_Enumerator$/func (o NullBackend) \1(p.Ucred, p.\2) p.\3_Enumerator { return \3_Ø{} }/p') +$(< "$interface" sed -rn 's/^\t([^(]+)\(Ucred, ([^)]+)\) <-chan (\S+)$/func (o NullBackend) \1(p.Ucred, p.\2) <-chan p.\3 { r := make(chan p.\3); close(r); return r }/p') var _ p.Backend = NullBackend{} EOF |