1
0
mirror of https://github.com/MontFerret/ferret.git synced 2024-12-16 11:37:36 +02:00
ferret/pkg/drivers/type.go

46 lines
813 B
Go
Raw Normal View History

package drivers
import "github.com/MontFerret/ferret/pkg/runtime/core"
var (
2019-09-30 20:00:13 +02:00
HTTPResponseType = core.NewType("HTTPResponse")
HTTPHeaderType = core.NewType("HTTPHeaders")
HTTPCookieType = core.NewType("HTTPCookie")
HTMLElementType = core.NewType("HTMLElement")
HTMLDocumentType = core.NewType("HTMLDocument")
HTMLPageType = core.NewType("HTMLPageType")
)
// Comparison table of builtin types
var typeComparisonTable = map[core.Type]uint64{
HTTPHeaderType: 0,
HTTPCookieType: 1,
HTMLElementType: 2,
HTMLDocumentType: 3,
HTMLPageType: 4,
}
func Compare(first, second core.Type) int64 {
f, ok := typeComparisonTable[first]
if !ok {
return -1
}
s, ok := typeComparisonTable[second]
if !ok {
return -1
}
if f == s {
return 0
}
if f > s {
return 1
}
return -1
}