Skip to content

Commit

Permalink
Merge pull request #24 from fcard/fix_deprecations_05
Browse files Browse the repository at this point in the history
Remove deprecated syntax and functions (call,symbol,readall)
  • Loading branch information
fcard authored Sep 25, 2016
2 parents af7d269 + 8b8ffc9 commit 6747b08
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion examples/classprep.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract Object
immutable Method{T <: Object}
func :: Function
end
Base.call(m::Method, args...) = m.func(args...)
(m::Method)(args...) = m.func(args...)

class_field_values(obj) =
filter(x->!isa(x, Method), map(x->getfield(obj, x), fieldnames(obj)))
Expand Down
2 changes: 1 addition & 1 deletion src/Analyzer/Function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function is_macro_name(x::Symbol)
end

function newbinding(ex)
name = is_macro_name(ex)? symbol(string(ex)[2:end]) : ex
name = is_macro_name(ex)? Symbol(string(ex)[2:end]) : ex
Binding(name)
end

Expand Down
4 changes: 2 additions & 2 deletions src/Dispatch/Applications.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const MACROMETHODS = TopMetaTable()
end

function macromet(name, patterns, label, body, mod)
init_metatable!(MACROMETHODS, mod, symbol("@$name"), "macromethod $name")
macrotable = get_metatable(MACROMETHODS, mod, symbol("@$name"))
init_metatable!(MACROMETHODS, mod, Symbol("@$name"), "macromethod $name")
macrotable = get_metatable(MACROMETHODS, mod, Symbol("@$name"))
undefined = isempty(macrotable.methods)

code =
Expand Down
6 changes: 3 additions & 3 deletions src/Dispatch/BaseImplementations.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module BaseImplementation
using ...Dispatch.Structure
import Base: showerror, ==, call, show, display
import Base: showerror, ==, show, display


call(met::MetaMethod, exprs...) = met.method(exprs...)
(met::MetaMethod)(exprs...) = met.method(exprs...)

function show(io::IO, met::MetaMethod)
args = map(met.tree.child.children) do tree
Expand Down Expand Up @@ -33,4 +33,4 @@ end
showerror(io::IO, err::MetaMethodError) =
print(io, "$(err.name) has no method that matches $(err.expr).")

end
end
4 changes: 2 additions & 2 deletions src/Dispatch/MetaModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function importallcode(path)

for exp in $union(metafun_exports, macromet_exports)
imp = Expr(:import, $vcat($path, exp)...)
eval(Expr(:macrocall, symbol("@metamodule"), imp))
eval(Expr(:macrocall, Symbol("@metamodule"), imp))
end
end
end
Expand All @@ -70,4 +70,4 @@ gettable(name) =
startswith(string(name), "@")? MM : MF


end
end
4 changes: 2 additions & 2 deletions src/Dispatch/Reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import ...Dispatch.TableManipulation: print_conflicts
import Base.Meta: quot
export @prefer, @whichmeta, @remove, @importmeta, @metamethods, @metaconflicts

name(macroname) = symbol(string(macroname)[1:end])
name(macroname) = Symbol(string(macroname)[1:end])

macrotable(macroname,M) =
get_metatable(MACROMETHODS, M, name(macroname))
Expand Down Expand Up @@ -97,4 +97,4 @@ conflictscode(m, typ, M=current_module()) =
@macromethod metaconflicts(M.@m) = esc(conflictscode(m, :macro, M))


end
end
14 changes: 6 additions & 8 deletions src/PatternStructure/Checks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ immutable QuoteStep <: PatternStep end
immutable IterStep <: PatternStep end
immutable SlurpStep <: PatternStep end

import Base: call
(::ArgsStep)(ex) = ex.args
(::BlockStep)(ex) = linesof(ex)

call(::ArgsStep, ex) = ex.args
call(::BlockStep, ex) = linesof(ex)
(::QuoteStep)(ex::Expr) = ex.args
(::QuoteStep)(ex::QuoteNode) = [ex.value]

call(::QuoteStep, ex::Expr) = ex.args
call(::QuoteStep, ex::QuoteNode) = [ex.value]

call(::IterStep, ex) = ex
call(::SlurpStep, ex) = error("Called the step of slurp.")
(::IterStep)(ex) = ex
(::SlurpStep)(ex) = error("Called the step of slurp.")

end
2 changes: 1 addition & 1 deletion src/PatternStructure/Printing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function expr(p::PatternNode)
children::Vector{Any} = map(expr, p.children)

if is_macrocall(p.head)
children[1] = symbol("@$(children[1])")
children[1] = Symbol("@$(children[1])")
end

is_special(p)?
Expand Down
4 changes: 2 additions & 2 deletions test/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ MF = Dispatch.Applications.METAFUNCTIONS[ReflectionTests]
@metafunction m(x) = [x]
@metafunction m(x+y) = [x,y]

const mmac = symbol("@m")
const mmac = Symbol("@m")
const mfun = :m

@test MM[mmac].methods[1] == @whichmeta @m(x+y)
Expand Down Expand Up @@ -145,4 +145,4 @@ end

@test B.@m(x+y,y+x) == (:x,:y)

end
end

0 comments on commit 6747b08

Please sign in to comment.