Skip to content

Commit

Permalink
Fix rewriter for version-gated expressions (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
christiangnrd authored Feb 4, 2025
1 parent b8ab3b6 commit 924a130
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions res/wrap/wrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ end

function stripStatic(expr::Expr)
if expr.head == :macrocall && first(expr.args) == Symbol("@static")
return expr.args[3].args[2].args[1]
return expr.args[3].args[2].args
else
return expr
return [expr]
end
end

Expand All @@ -176,25 +176,31 @@ function rewriter!(ctx, options)

nodetype = typeof(node)
if nodetype <: Generators.ExprNode{<:Generators.AbstractObjCObjNodeType}
declexpr = node.exprs[1]
nostatic_exprs = if length(node.exprs) > 1
node.exprs
else
stripStatic(node.exprs[1])
end

declexpr = nostatic_exprs[1]

if haskey(nodedict, "immutable")
declexpr = node.exprs[1]
con = nodedict["immutable"]

declexpr.args[3].args[2] = con
end
if haskey(nodedict, "supertype")
expr2 = stripStatic(declexpr).args[4]
expr2 = declexpr.args[4]
typ = nodedict["supertype"] |> Meta.parse

expr2.args[2] = typ
end
if haskey(nodedict, "proptype")
proptypedict = nodedict["proptype"]
propertyexprs = node.exprs[2].args[4].args

propertyexprs = nostatic_exprs[2].args[4].args
for pro in propertyexprs
isnothing(pro) && continue
strippedpro = stripStatic(pro)
strippedpro = stripStatic(pro)[1]
propname = strippedpro.args[3].args[1]
if haskey(proptypedict, string(propname))
newtype = proptypedict[string(propname)] |> Meta.parse
Expand Down

0 comments on commit 924a130

Please sign in to comment.