The function parameter model has been modified to support the passing of named parameters
This commit is contained in:
+9
-6
@@ -9,18 +9,21 @@ import (
|
||||
"os"
|
||||
)
|
||||
|
||||
func importFunc(ctx ExprContext, name string, args []any) (result any, err error) {
|
||||
func importFunc(ctx ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
return importGeneral(ctx, name, args)
|
||||
}
|
||||
|
||||
func importAllFunc(ctx ExprContext, name string, args []any) (result any, err error) {
|
||||
func importAllFunc(ctx ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
CtrlEnable(ctx, control_export_all)
|
||||
return importGeneral(ctx, name, args)
|
||||
}
|
||||
|
||||
func importGeneral(ctx ExprContext, name string, args []any) (result any, err error) {
|
||||
func importGeneral(ctx ExprContext, name string, args map[string]any) (result any, err error) {
|
||||
dirList := buildSearchDirList("sources", ENV_EXPR_SOURCE_PATH)
|
||||
result, err = doImport(ctx, name, dirList, NewArrayIterator(args))
|
||||
if v, exists := args[ParamFilepath]; exists && v != nil {
|
||||
argv := v.([]any)
|
||||
result, err = doImport(ctx, name, dirList, NewArrayIterator(argv))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -62,10 +65,10 @@ func doImport(ctx ExprContext, name string, dirList []string, it Iterator) (resu
|
||||
}
|
||||
|
||||
func ImportImportFuncs(ctx ExprContext) {
|
||||
ctx.RegisterFunc("import", NewGolangFunctor(importFunc), TypeAny, []ExprFuncParam{
|
||||
ctx.RegisterFunc("import", NewGolangFunctor2(importFunc), TypeAny, []ExprFuncParam{
|
||||
NewFuncParamFlag(ParamFilepath, PfRepeat),
|
||||
})
|
||||
ctx.RegisterFunc("importAll", NewGolangFunctor(importAllFunc), TypeAny, []ExprFuncParam{
|
||||
ctx.RegisterFunc("importAll", NewGolangFunctor2(importAllFunc), TypeAny, []ExprFuncParam{
|
||||
NewFuncParamFlag(ParamFilepath, PfRepeat),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user