implements: stub in the initial support for functions pulled from C

These types will be used to track what C functions are expected to be
implemented.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-05-04 15:00:53 -04:00 committed by John Mulligan
parent 80300e4e5a
commit ce7911ea35

View File

@ -0,0 +1,32 @@
package implements
import (
"fmt"
"strings"
)
// CFunction represents a function in C code.
type CFunction struct {
Name string `xml:"name,attr"`
Attr string `xml:"attributes,attr"`
}
// isDeprecated will return true if the C function is marked deprecated
// via attributes.
func (cf CFunction) isDeprecated() bool {
return strings.Contains(cf.Attr, "deprecated")
}
// CFunctions is a sortable slice of CFunction.
type CFunctions []CFunction
func (cfs CFunctions) Len() int { return len(cfs) }
func (cfs CFunctions) Swap(i, j int) { cfs[i], cfs[j] = cfs[j], cfs[i] }
func (cfs CFunctions) Less(i, j int) bool { return cfs[i].Name < cfs[j].Name }
func (cfs CFunctions) ensure() (CFunctions, error) {
if len(cfs) < 1 {
return nil, fmt.Errorf("found %d c functions", len(cfs))
}
return cfs, nil
}