Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 6, 2024
1 parent 7979503 commit 687d46d
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions src/JuMP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1307,28 +1307,15 @@ include("print.jl")
# `MOI.OPTIMAL`. This piece of code re-exports them from JuMP so that users can
# use: `MOI.OPTIMAL`, `JuMP.OPTIMAL`, or `using JuMP; OPTIMAL`.

function _eval_instances_in_jump(moi_enum)
for enum in instances(moi_enum)
name = Symbol(enum)
# `eval` the instance as `const name = MOI.name`.
eval(Expr(:const, Expr(:(=), name, enum)))
# Documentation is not copied for a `const` expression of an object, so
# we need to manually set the docstring.
docstr = Docs.docstr(Docs.Binding(MOI, name))
Docs.doc!(@__MODULE__, Docs.Binding(@__MODULE__, name), docstr)
for sym in [:ResultStatusCode, :TerminationStatusCode, :OptimizationSense]
@eval const $sym = MOI.$sym
for enum in instances(getfield(MOI, sym))
@eval const $(Symbol(enum)) = $enum
docstr = Docs.docstr(Docs.Binding(MOI, Symbol(enum)))
Docs.doc!(@__MODULE__, Docs.Binding(@__MODULE__, Symbol(enum)), docstr)
end
return
end

const ResultStatusCode = MOI.ResultStatusCode
_eval_instances_in_jump(MOI.ResultStatusCode)

const TerminationStatusCode = MOI.TerminationStatusCode
_eval_instances_in_jump(MOI.TerminationStatusCode)

const OptimizationSense = MOI.OptimizationSense
_eval_instances_in_jump(MOI.OptimizationSense)

# JuMP exports everything except internal symbols, which are defined as those
# whose name starts with an underscore. Macros whose names start with
# underscores are internal as well. If you don't want all of these symbols
Expand Down

0 comments on commit 687d46d

Please sign in to comment.