Skip to content

Commit

Permalink
fixed n digits conversion for enums #69
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemapfel committed Feb 8, 2024
1 parent 62506e3 commit 002d730
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Mousetrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,9 @@ module Mousetrap
enum_sym = QuoteNode(enum)
to_int_name = Symbol(enum) * :_to_int

push!(out.args, :(Base.ndigits(x::$enum) = ndigits(Mousetrap.detail.$to_int_name(x))))
push!(out.args, :(Base.string(x::$enum) = string(Mousetrap.detail.$to_int_name(x))))
push!(out.args, :(Base.convert(::Type{Integer}, x::$enum) = Integer(Mousetrap.detail.to_int_name(x))))
push!(out.args, :(Base.convert(::Type{Integer}, x::$enum) = Integer(Mousetrap.detail.$to_int_name(x))))
push!(out.args, :(Base.instances(x::Type{$enum}) = [$(names...)]))
push!(out.args, :(Base.show(io::IO, x::Type{$enum}) = print(io, (isdefined(Main, $enum_sym) ? "" : "Mousetrap.") * $enum_str)))
push!(out.args, :(Base.show(io::IO, x::$enum) = print(io, string($enum) * "(" * string(convert(Int64, x)) * ")")))
Expand Down

0 comments on commit 002d730

Please sign in to comment.