using HYPRE.LibHYPRE function generate_options(io, structname, prefix) println(io, "") println(io, "function Internals.set_options(s::$(structname), kwargs)") println(io, " solver = s.solver") println(io, " for (k, v) in kwargs") r = Regex("^" * prefix * "([A-Z].*)\$") ns = sort!(filter!(x -> occursin(r, string(x)), names(LibHYPRE))) first = true for n in ns m = get(methods(getfield(LibHYPRE, n)), 1, nothing) m === nothing && continue nargs = m.nargs - 1 k = String(match(r, string(n))[1]) print(io, " $(first ? "" : "else")if k === :$(k)") println(io) if k == "Precond" println(io, " Internals.set_precond(s, v)") elseif nargs == 1 println(io, " @check ", n, "(solver)") elseif nargs == 2 println(io, " @check ", n, "(solver, v)") else # nargs >= 3 println(io, " @check ", n, "(solver, v...)") end first = false end println(io, " end") println(io, " end") println(io, "end") end open(joinpath(@__DIR__, "..", "src", "solver_options.jl"), "w") do io println(io, "# SPDX-License-Identifier: MIT") println(io, "") println(io, "# This file is automatically generated by gen/solver_options.jl") println(io, "") println(io, "Internals.set_options(::HYPRESolver, kwargs) = nothing") generate_options(io, "BoomerAMG", "HYPRE_BoomerAMGSet") generate_options(io, "PCG", "HYPRE_PCGSet") end