diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-08-28 22:17:34 -0600 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2015-08-28 22:17:34 -0600 |
commit | 5fd4b54f3a833bdfabf067c4abafa56c11e02ab1 (patch) | |
tree | a0f2e720ef46709c6b59e4bcf8036f10831fe64c /src/nslcd_proto/util | |
parent | b55355121e0ed259097254447f16739b0f3da61d (diff) |
Clean up, based on making godoc slightly more readable
Diffstat (limited to 'src/nslcd_proto/util')
-rw-r--r-- | src/nslcd_proto/util/enumerator@T.got | 40 | ||||
-rwxr-xr-x | src/nslcd_proto/util/struct_null_backend.go.sh | 14 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/nslcd_proto/util/enumerator@T.got b/src/nslcd_proto/util/enumerator@T.got new file mode 100644 index 0000000..e1dd2ae --- /dev/null +++ b/src/nslcd_proto/util/enumerator@T.got @@ -0,0 +1,40 @@ +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) { + return o.GetNext() +} + +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 new file mode 100755 index 0000000..7cbdbd0 --- /dev/null +++ b/src/nslcd_proto/util/struct_null_backend.go.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# -*- Mode: Go -*- +interface=$1 +cat <<EOF +package util + +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') + +var _ p.Backend = NullBackend{} +EOF |