Skip to content

Commit

Permalink
Use different version if Revise is tracking proto (#36)
Browse files Browse the repository at this point in the history
* Use different version if Revise is tracking proto

* Update ProtoStruct.jl

Co-authored-by: Eben60 <[email protected]>

---------

Co-authored-by: Eben60 <[email protected]>
  • Loading branch information
Tortar and Eben60 authored Feb 19, 2024
1 parent b1849da commit c8345eb
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/ProtoStruct.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@

const revise_uuid = Base.UUID("295af30f-e4ad-537b-8983-00126c2a3abe")
const revise_pkgid = Base.PkgId(revise_uuid, "Revise")

function checkrev()
revise_pkgid in keys(Base.loaded_modules) || return false
d = @__DIR__
f = splitpath(@__FILE__)[end]
watched_files = getproperty(Base.loaded_modules[revise_pkgid], :watched_files)
d in keys(watched_files) || return false
trackedfiles = watched_files[d].trackedfiles
return f in keys(trackedfiles)
end

macro proto(expr)
if checkrev()
@eval __module__ $(_proto(expr))
return
else
return esc(_proto(expr))
end
end

function _proto(expr)
if expr.head == :macrocall && expr.args[1] == Symbol("@kwdef")
expr = expr.args[3]
end
Expand Down Expand Up @@ -230,6 +252,6 @@ macro proto(expr)
end
end
end
return esc(ex)
return ex
end

0 comments on commit c8345eb

Please sign in to comment.