Skip to content

Commit

Permalink
add generated code notice
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Oct 26, 2017
1 parent c3e6907 commit 87c7011
Show file tree
Hide file tree
Showing 26 changed files with 182 additions and 9 deletions.
4 changes: 3 additions & 1 deletion cmd/datagen/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

func heap() cli.Command {
Expand Down Expand Up @@ -45,6 +45,8 @@ has good performance and is well tested, with 100% test coverage.
src := []byte(heapSrc)
src = bytes.Replace(src, []byte("package heap"), []byte(pkgname), 1)

src = bytes.Replace(src, []byte("// GENERATED CODE!!!"), []byte(generatedCodeComment()), 1)

// need to replace Compare before replacing KType
src = replaceHeapCompareFunc(ktype, src)
src = bytes.Replace(src, []byte("KType"), []byte(ktype), -1)
Expand Down
15 changes: 14 additions & 1 deletion cmd/datagen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
package main

import (
"fmt"
"log"
"os"
"strings"

"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

func main() {
Expand Down Expand Up @@ -55,3 +57,14 @@ func valOrDefault(ctx *cli.Context, f cli.StringFlag) string {
}
return f.Value
}

func generatedCodeComment() string {
return fmt.Sprintf(`// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// %s`, strings.Join(os.Args, " "))
}
4 changes: 3 additions & 1 deletion cmd/datagen/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

func queue() cli.Command {
Expand Down Expand Up @@ -44,6 +44,8 @@ is based on a ring buffer, which has good performance and is well tested.
src := []byte(queueSrc)
src = bytes.Replace(src, []byte("package queue"), []byte(pkgname), 1)

src = bytes.Replace(src, []byte("// GENERATED CODE!!!"), []byte(generatedCodeComment()), 1)

src = bytes.Replace(src, []byte("nilKType"), []byte("nil"+kname), -1) // before KType's replace
src = bytes.Replace(src, []byte("KType"), []byte(ktype), -1)
src = bytes.Replace(src, []byte("Queue"), []byte(typeName), -1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/datagen/sorted_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"strings"

"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

func sortedMap() cli.Command {
Expand Down Expand Up @@ -58,6 +58,8 @@ generated with the custom type)`,
src := []byte(redblackbstMapSrc)
src = bytes.Replace(src, []byte("package redblackbst"), []byte(pkgname), 1)

src = bytes.Replace(src, []byte("// GENERATED CODE!!!"), []byte(generatedCodeComment()), 1)

// need to replace Compare before replacing KType
src = replaceRbstCompareFunc(ktype, src)
src = bytes.Replace(src, []byte("KType"), []byte(ktype), -1)
Expand Down
4 changes: 3 additions & 1 deletion cmd/datagen/sorted_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/codegangsta/cli"
"gopkg.in/urfave/cli.v1"
)

func sortedSet() cli.Command {
Expand Down Expand Up @@ -46,6 +46,8 @@ generated with the custom type)`,
src := []byte(redblackbstSetSrc)
src = bytes.Replace(src, []byte("package redblackbst"), []byte(pkgname), 1)

src = bytes.Replace(src, []byte("// GENERATED CODE!!!"), []byte(generatedCodeComment()), 1)

// need to replace Compare before replacing KType
src = replaceRbstCompareFunc(ktype, src)
src = bytes.Replace(src, []byte("KType"), []byte(ktype), -1)
Expand Down
8 changes: 4 additions & 4 deletions cmd/datagen/templates.go

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions codegen/heap_bytes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build167539603/command-line-arguments/_obj/exe/heap heap -key []byte

// Most of the implementation is adapted from Algorithms 4ed by Sedgewick
// and Wayne.

Expand Down
9 changes: 9 additions & 0 deletions codegen/heap_float.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build864907043/command-line-arguments/_obj/exe/heap heap -key float64

// Most of the implementation is adapted from Algorithms 4ed by Sedgewick
// and Wayne.

Expand Down
9 changes: 9 additions & 0 deletions codegen/heap_int.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build102855875/command-line-arguments/_obj/exe/heap heap -key int

// Most of the implementation is adapted from Algorithms 4ed by Sedgewick
// and Wayne.

Expand Down
9 changes: 9 additions & 0 deletions codegen/heap_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build650327363/command-line-arguments/_obj/exe/heap heap -key string

// Most of the implementation is adapted from Algorithms 4ed by Sedgewick
// and Wayne.

Expand Down
9 changes: 9 additions & 0 deletions codegen/queue_bytes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build686866363/command-line-arguments/_obj/exe/heap queue -key []byte

// Implementation adapted from github.com/eapache/queue:
// The MIT License (MIT)
// Copyright (c) 2014 Evan Huus
Expand Down
9 changes: 9 additions & 0 deletions codegen/queue_float.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build217327899/command-line-arguments/_obj/exe/heap queue -key float64

// Implementation adapted from github.com/eapache/queue:
// The MIT License (MIT)
// Copyright (c) 2014 Evan Huus
Expand Down
9 changes: 9 additions & 0 deletions codegen/queue_int.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build308087115/command-line-arguments/_obj/exe/heap queue -key int

// Implementation adapted from github.com/eapache/queue:
// The MIT License (MIT)
// Copyright (c) 2014 Evan Huus
Expand Down
9 changes: 9 additions & 0 deletions codegen/queue_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build635301755/command-line-arguments/_obj/exe/heap queue -key string

// Implementation adapted from github.com/eapache/queue:
// The MIT License (MIT)
// Copyright (c) 2014 Evan Huus
Expand Down
9 changes: 9 additions & 0 deletions codegen/smap_bytes_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build426387111/command-line-arguments/_obj/exe/heap smap -key []byte -val string

import "bytes"

// WARNING: using []byte as keys can lead to undefined behavior if the
Expand Down
9 changes: 9 additions & 0 deletions codegen/smap_float_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build089399687/command-line-arguments/_obj/exe/heap smap -key float64 -val string


func (r SortedFloat64ToStringMap) compare(a, b float64) int {
const e = 0.00000001
Expand Down
9 changes: 9 additions & 0 deletions codegen/smap_int_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build596923455/command-line-arguments/_obj/exe/heap smap -key int -val string

func (r SortedIntToStringMap) compare(a, b int) int { return int(a) - int(b) }

// SortedIntToStringMap is a sorted map built on a left leaning red black balanced
Expand Down
9 changes: 9 additions & 0 deletions codegen/smap_string_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build421216759/command-line-arguments/_obj/exe/heap smap -key string -val string


func (r SortedStringToStringMap) compare(a, b string) int {
if a < b {
Expand Down
9 changes: 9 additions & 0 deletions codegen/sset_bytes.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build808196515/command-line-arguments/_obj/exe/heap sset -key []byte

import "bytes"

// WARNING: using []byte as keys can lead to undefined behavior if the
Expand Down
9 changes: 9 additions & 0 deletions codegen/sset_float.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build177764915/command-line-arguments/_obj/exe/heap sset -key float64


func (r SortedFloat64Set) compare(a, b float64) int {
const e = 0.00000001
Expand Down
9 changes: 9 additions & 0 deletions codegen/sset_int.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build541103547/command-line-arguments/_obj/exe/heap sset -key int

func (r SortedIntSet) compare(a, b int) int { return int(a) - int(b) }

// SortedIntSet is a sorted set built on a left leaning red black balanced
Expand Down
9 changes: 9 additions & 0 deletions codegen/sset_string.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package codegen

// GENERATED CODE, DO NOT EDIT
// This code was generated by a tool.
//
// github.com/aybabtme/datagen
//
// The command that generated this was:
//
// /var/folders/ng/k4qlpfms3bd8m6g7rqn5rx1r0000gn/T/go-build081766871/command-line-arguments/_obj/exe/heap sset -key string


func (r SortedStringSet) compare(a, b string) int {
if a < b {
Expand Down
2 changes: 2 additions & 0 deletions heap/heap.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package heap

// GENERATED CODE!!!

// Most of the implementation is adapted from Algorithms 4ed by Sedgewick
// and Wayne.

Expand Down
2 changes: 2 additions & 0 deletions map/redblackbst/rbbst.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package redblackbst

// GENERATED CODE!!!

func (r RedBlack) compare(a, b KType) int { return a.Compare(b) }

// RedBlack is a sorted map built on a left leaning red black balanced
Expand Down
2 changes: 2 additions & 0 deletions queue/queue.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package queue

// GENERATED CODE!!!

// Implementation adapted from github.com/eapache/queue:
// The MIT License (MIT)
// Copyright (c) 2014 Evan Huus
Expand Down
2 changes: 2 additions & 0 deletions set/redblackbst/rbbst.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package redblackbst

// GENERATED CODE!!!

func (r RedBlack) compare(a, b KType) int { return a.Compare(b) }

// RedBlack is a sorted set built on a left leaning red black balanced
Expand Down

0 comments on commit 87c7011

Please sign in to comment.