diff --git a/context-helpers.go b/context-helpers.go index 20b2b92..303e78c 100644 --- a/context-helpers.go +++ b/context-helpers.go @@ -11,6 +11,20 @@ func cloneContext(sourceCtx ExprContext) (clonedCtx ExprContext) { 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) { exportAll := isEnabled(sourceCtx, control_export_all) // Export variables diff --git a/data-cursor.go b/data-cursor.go index ea8283a..66a45cc 100644 --- a/data-cursor.go +++ b/data-cursor.go @@ -52,8 +52,8 @@ func (dc *dataCursor) Next() (item any, err error) { // must return io.EOF after } else { dc.index++ } - exportObjects(dc.ctx, ctx) } + exportObjects(dc.ctx, ctx) return }