moved the exportVar() and exportFunc() functions from data-cursor.go to context-helpers.go

This commit is contained in:
Celestino Amoroso 2024-04-27 06:16:11 +02:00
parent 70892aa980
commit 361b84f31f
2 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,20 @@ func cloneContext(sourceCtx ExprContext) (clonedCtx ExprContext) {
return return
} }
func exportVar(ctx ExprContext, name string, value any) {
if name[0] == '@' {
name = name[1:]
}
ctx.setVar(name, value)
}
func exportFunc(ctx ExprContext, name string, info ExprFunc) {
if name[0] == '@' {
name = name[1:]
}
ctx.RegisterFunc(name, info.Functor(), info.MinArgs(), info.MaxArgs())
}
func exportObjects(destCtx, sourceCtx ExprContext) { func exportObjects(destCtx, sourceCtx ExprContext) {
exportAll := isEnabled(sourceCtx, control_export_all) exportAll := isEnabled(sourceCtx, control_export_all)
// Export variables // Export variables

View File

@ -52,8 +52,8 @@ func (dc *dataCursor) Next() (item any, err error) { // must return io.EOF after
} else { } else {
dc.index++ dc.index++
} }
exportObjects(dc.ctx, ctx)
} }
exportObjects(dc.ctx, ctx)
return return
} }