mirror of
https://github.com/ceph/go-ceph
synced 2024-12-25 07:32:27 +00:00
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:
parent
80300e4e5a
commit
ce7911ea35
32
contrib/implements/internal/implements/cfunctions.go
Normal file
32
contrib/implements/internal/implements/cfunctions.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user