-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
96 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
package main | ||
|
||
import "sort" | ||
|
||
// An enumerated value. | ||
type Enum struct { | ||
Name string // Raw specification name | ||
GoName string // Go name with the API prefix stripped | ||
Value string // Raw specification value | ||
} | ||
|
||
type Enums map[string]*Enum | ||
type SortedEnums []*Enum | ||
|
||
func (f SortedEnums) Len() int { return len(f) } | ||
func (f SortedEnums) Swap(i, j int) { f[i], f[j] = f[j], f[i] } | ||
func (f SortedEnums) Less(i, j int) bool { return f[i].Name < f[j].Name } | ||
|
||
func (es Enums) Sort() SortedEnums { | ||
sortedEnums := make(SortedEnums, 0, len(es)) | ||
for _, e := range es { | ||
sortedEnums = append(sortedEnums, e) | ||
} | ||
sort.Sort(sortedEnums) | ||
return sortedEnums | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.