summaryrefslogtreecommitdiff
path: root/newsort.go
blob: b931977e92c7c7732c990c7c65feff559e35b34a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main

import (
	"os"
)

func (pb *Files) makeNewSortfile(pf *File) error {
	f, _ := os.OpenFile(pf.Filebase+".newsort.pb.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)

	header(f, pf)
	pf.syncLock(f)

	if argv.Mutex {
		// use the mutex lock from the modified protoc.pb.go file
		pf.Bases.Lockname = "all.Lock"
	}

	pf.Base.iterTop(f)
	pf.Base.iterNext(f)
	pf.iterSelect(f)
	pf.appendUnique(f) // Append() enforce no unique keys
	pf.iterSortBy(f)
	pf.iterAll(f)
	// pf.iterSortAll(f, sortmap)

	return nil

	/*
		for _, s := range uniqueKeys {
			// log.Info("found unique key in .proto", s)
			sortmap["sortBy"] = s
			sortmap["sortKey"] = s

			sortmap["append"] = sortmap["sortKey"]
			iterAppend(f, sortmap) // Append() enforce unique key argv.Append

			iterDelete(f, sortmap)
			iterReplace(f, sortmap)
			iterFind(f, sortmap)
		}

		for _, s := range argv.Sort {
			sortparts := strings.Split(s, ",")
			sortmap["sortBy"] = sortparts[0]
			sortmap["sortKey"] = sortparts[1]

			iterSortBy(f, sortmap)

			sortmap["append"] = sortmap["sortKey"]
			iterAppend(f, sortmap) // Append() enforce unique key argv.Append

			iterDelete(f, sortmap)
			iterReplace(f, sortmap)
			iterFind(f, sortmap)
		}
	*/
	return nil
}