API

The wrapper registers its C++ API with CxxWrap.jl. Giac.jl builds its Julia interface on it; you only call these names directly when working on the wrapper or on Giac.jl itself.

Evaluation

Function dispatch

Gen, an opaque giac::gen

From Julia, build small integers with Gen(Int32(n)): CxxWrap does not tell the int64_t and double constructors apart, so Gen(Int64(n)) gives a floating-point Gen.

Log capture

GIAC writes informational messages to its log stream (stderr by default), for instance // ∫ ~= 0.272198261288 when a definite integral is returned unevaluated. The capture API redirects that stream to an in-memory buffer, so the text can be retrieved separately from the result:

log_capture_begin()
value = giac_eval("integrate(ln(1+x)/(1+x^2),x,0,1)")
log = log_capture_end()      # "// ∫ ~= 0.272198261288\n"
to_string(value)             # "integrate(ln(1+x)/(1+x^2),x,0,1)"

Giac.jl wraps this as evaluate_with_diagnostics.

Help and introspection

Contexts and configuration

Calling the wrapper from Julia directly

# From the repository root, after `meson compile -C builddir`.
using CxxWrap
const libgiac = joinpath(pwd(), "builddir", "src", "libgiac_wrapper")
@wrapmodule(() -> libgiac)
@initcxx

r = giac_eval("sin(x)+1")
to_string(r)                       # "sin(x)+1"

ctx1 = GiacContext()
ctx2 = GiacContext()
giac_eval("a := 5", ctx1)
to_string(giac_eval("a", ctx1))    # "5"
to_string(giac_eval("a", ctx2))    # "a": ctx2 never saw the binding