lang: funcs: core: Make module names public

This is needed for when we have nested modules.
This commit is contained in:
James Shubin
2019-05-20 08:45:43 -04:00
parent d5074871c7
commit 12582e963d
35 changed files with 49 additions and 49 deletions

View File

@@ -18,6 +18,6 @@
package coredatetime
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "datetime"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "datetime"
)

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
facts.ModuleRegister(moduleName, "now", func() facts.Fact { return &DateTimeFact{} }) // must register the fact and name
facts.ModuleRegister(ModuleName, "now", func() facts.Fact { return &DateTimeFact{} }) // must register the fact and name
}
// DateTimeFact is a fact which returns the current date and time.

View File

@@ -27,7 +27,7 @@ import (
func init() {
// FIXME: consider renaming this to printf, and add in a format string?
simple.ModuleRegister(moduleName, "print", &types.FuncValue{
simple.ModuleRegister(ModuleName, "print", &types.FuncValue{
T: types.NewType("func(a int) str"),
V: func(input []types.Value) (types.Value, error) {
epochDelta := input[0].Int()

View File

@@ -27,7 +27,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "weekday", &types.FuncValue{
simple.ModuleRegister(ModuleName, "weekday", &types.FuncValue{
T: types.NewType("func(a int) str"),
V: Weekday,
})

View File

@@ -26,7 +26,7 @@ import (
const Answer = 42
func init() {
simple.ModuleRegister(moduleName, "answer", &types.FuncValue{
simple.ModuleRegister(ModuleName, "answer", &types.FuncValue{
T: types.NewType("func() int"),
V: func([]types.Value) (types.Value, error) {
return &types.IntValue{V: Answer}, nil

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "errorbool", &types.FuncValue{
simple.ModuleRegister(ModuleName, "errorbool", &types.FuncValue{
T: types.NewType("func(a bool) str"),
V: func(input []types.Value) (types.Value, error) {
if input[0].Bool() {

View File

@@ -18,6 +18,6 @@
package coreexample
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "example"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "example"
)

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
facts.ModuleRegister(moduleName, "flipflop", func() facts.Fact { return &FlipFlopFact{} }) // must register the fact and name
facts.ModuleRegister(ModuleName, "flipflop", func() facts.Fact { return &FlipFlopFact{} }) // must register the fact and name
}
// FlipFlopFact is a fact which flips a bool repeatedly. This is an example fact

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "int2str", &types.FuncValue{
simple.ModuleRegister(ModuleName, "int2str", &types.FuncValue{
T: types.NewType("func(a int) str"),
V: func(input []types.Value) (types.Value, error) {
return &types.StrValue{

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "str2int", &types.FuncValue{
simple.ModuleRegister(ModuleName, "str2int", &types.FuncValue{
T: types.NewType("func(a str) int"),
V: func(input []types.Value) (types.Value, error) {
var i int64

View File

@@ -33,7 +33,7 @@ import (
)
func init() {
funcs.ModuleRegister(moduleName, "vumeter", func() interfaces.Func { return &VUMeterFunc{} }) // must register the func and name
funcs.ModuleRegister(ModuleName, "vumeter", func() interfaces.Func { return &VUMeterFunc{} }) // must register the func and name
}
// VUMeterFunc is a gimmic function to display a vu meter from the microphone.

View File

@@ -18,6 +18,6 @@
package corefmt
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "fmt"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "fmt"
)

View File

@@ -29,7 +29,7 @@ import (
func init() {
// FIXME: should this be named sprintf instead?
funcs.ModuleRegister(moduleName, "printf", func() interfaces.Func { return &PrintfFunc{} })
funcs.ModuleRegister(ModuleName, "printf", func() interfaces.Func { return &PrintfFunc{} })
}
const (

View File

@@ -18,6 +18,6 @@
package coremath
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "math"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "math"
)

View File

@@ -26,7 +26,7 @@ import (
)
func init() {
simplepoly.ModuleRegister(moduleName, "mod", []*types.FuncValue{
simplepoly.ModuleRegister(ModuleName, "mod", []*types.FuncValue{
{
T: types.NewType("func(int, int) int"),
V: Mod,

View File

@@ -26,7 +26,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "pow", &types.FuncValue{
simple.ModuleRegister(ModuleName, "pow", &types.FuncValue{
T: types.NewType("func(x float, y float) float"),
V: Pow,
})

View File

@@ -26,7 +26,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "sqrt", &types.FuncValue{
simple.ModuleRegister(ModuleName, "sqrt", &types.FuncValue{
T: types.NewType("func(x float) float"),
V: Sqrt,
})

View File

@@ -26,15 +26,15 @@ import (
func init() {
// TODO: Create a family method that will return a giant struct.
simple.ModuleRegister(moduleName, "is_debian", &types.FuncValue{
simple.ModuleRegister(ModuleName, "is_debian", &types.FuncValue{
T: types.NewType("func() bool"),
V: IsDebian,
})
simple.ModuleRegister(moduleName, "is_redhat", &types.FuncValue{
simple.ModuleRegister(ModuleName, "is_redhat", &types.FuncValue{
T: types.NewType("func() bool"),
V: IsRedHat,
})
simple.ModuleRegister(moduleName, "is_archlinux", &types.FuncValue{
simple.ModuleRegister(ModuleName, "is_archlinux", &types.FuncValue{
T: types.NewType("func() bool"),
V: IsArchLinux,
})

View File

@@ -18,6 +18,6 @@
package coreos
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "os"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "os"
)

View File

@@ -30,7 +30,7 @@ import (
)
func init() {
funcs.ModuleRegister(moduleName, "readfile", func() interfaces.Func { return &ReadFileFunc{} }) // must register the func and name
funcs.ModuleRegister(ModuleName, "readfile", func() interfaces.Func { return &ReadFileFunc{} }) // must register the func and name
}
// ReadFileFunc is a function that reads the full contents from a local file. If

View File

@@ -26,7 +26,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "match", &types.FuncValue{
simple.ModuleRegister(ModuleName, "match", &types.FuncValue{
T: types.NewType("func(pattern str, s str) bool"),
V: Match,
})

View File

@@ -18,6 +18,6 @@
package coreregexp
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "regexp"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "regexp"
)

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "split", &types.FuncValue{
simple.ModuleRegister(ModuleName, "split", &types.FuncValue{
T: types.NewType("func(a str, b str) []str"),
V: Split,
})

View File

@@ -18,6 +18,6 @@
package corestrings
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "strings"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "strings"
)

View File

@@ -25,7 +25,7 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "to_lower", &types.FuncValue{
simple.ModuleRegister(ModuleName, "to_lower", &types.FuncValue{
T: types.NewType("func(a str) str"),
V: ToLower,
})

View File

@@ -41,7 +41,7 @@ const (
)
func init() {
facts.ModuleRegister(moduleName, "cpu_count", func() facts.Fact { return &CPUCountFact{} }) // must register the fact and name
facts.ModuleRegister(ModuleName, "cpu_count", func() facts.Fact { return &CPUCountFact{} }) // must register the fact and name
}
// CPUCountFact is a fact that returns the current CPU count.

View File

@@ -26,19 +26,19 @@ import (
)
func init() {
simple.ModuleRegister(moduleName, "getenv", &types.FuncValue{
simple.ModuleRegister(ModuleName, "getenv", &types.FuncValue{
T: types.NewType("func(str) str"),
V: GetEnv,
})
simple.ModuleRegister(moduleName, "defaultenv", &types.FuncValue{
simple.ModuleRegister(ModuleName, "defaultenv", &types.FuncValue{
T: types.NewType("func(str, str) str"),
V: DefaultEnv,
})
simple.ModuleRegister(moduleName, "hasenv", &types.FuncValue{
simple.ModuleRegister(ModuleName, "hasenv", &types.FuncValue{
T: types.NewType("func(str) bool"),
V: HasEnv,
})
simple.ModuleRegister(moduleName, "env", &types.FuncValue{
simple.ModuleRegister(ModuleName, "env", &types.FuncValue{
T: types.NewType("func() map{str: str}"),
V: Env,
})

View File

@@ -23,7 +23,7 @@ import (
)
func init() {
facts.ModuleRegister(moduleName, "hostname", func() facts.Fact { return &HostnameFact{} }) // must register the fact and name
facts.ModuleRegister(ModuleName, "hostname", func() facts.Fact { return &HostnameFact{} }) // must register the fact and name
}
// HostnameFact is a function that returns the hostname.

View File

@@ -30,7 +30,7 @@ const (
)
func init() {
facts.ModuleRegister(moduleName, "load", func() facts.Fact { return &LoadFact{} }) // must register the fact and name
facts.ModuleRegister(ModuleName, "load", func() facts.Fact { return &LoadFact{} }) // must register the fact and name
}
// LoadFact is a fact which returns the current system load.

View File

@@ -18,6 +18,6 @@
package coresys
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "sys"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "sys"
)

View File

@@ -26,7 +26,7 @@ import (
)
func init() {
facts.ModuleRegister(moduleName, "uptime", func() facts.Fact { return &UptimeFact{} })
facts.ModuleRegister(ModuleName, "uptime", func() facts.Fact { return &UptimeFact{} })
}
// UptimeFact is a fact which returns the current uptime of your system.

View File

@@ -28,7 +28,7 @@ import (
)
func init() {
funcs.ModuleRegister(moduleName, "exchange", func() interfaces.Func { return &ExchangeFunc{} })
funcs.ModuleRegister(ModuleName, "exchange", func() interfaces.Func { return &ExchangeFunc{} })
}
// ExchangeFunc is special function which returns all the values of a given key

View File

@@ -28,7 +28,7 @@ import (
)
func init() {
funcs.ModuleRegister(moduleName, "kvlookup", func() interfaces.Func { return &KVLookupFunc{} })
funcs.ModuleRegister(ModuleName, "kvlookup", func() interfaces.Func { return &KVLookupFunc{} })
}
// KVLookupFunc is special function which returns all the values of a given key

View File

@@ -46,7 +46,7 @@ const (
)
func init() {
funcs.ModuleRegister(moduleName, "schedule", func() interfaces.Func { return &SchedulePolyFunc{} })
funcs.ModuleRegister(ModuleName, "schedule", func() interfaces.Func { return &SchedulePolyFunc{} })
}
// SchedulePolyFunc is special function which determines where code should run

View File

@@ -18,6 +18,6 @@
package coreworld
const (
// moduleName is the prefix given to all the functions in this module.
moduleName = "world"
// ModuleName is the prefix given to all the functions in this module.
ModuleName = "world"
)