From 361b84f31f7cb7794f3f089d31e50fd720fa9287 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sat, 27 Apr 2024 06:16:11 +0200 Subject: [PATCH] moved the exportVar() and exportFunc() functions from data-cursor.go to context-helpers.go --- context-helpers.go | 14 ++++++++++++++ data-cursor.go | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) 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 }