Skip to content

Commit

Permalink
JuliaInterface: move macros to macros.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Jun 16, 2019
1 parent 766b0e4 commit 52be909
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 40 deletions.
39 changes: 0 additions & 39 deletions pkg/GAPJulia/JuliaInterface/julia/gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,6 @@ for (left, right) in typecombinations
end


"""
@gap <obj>
@gap(<obj>)
Executes <obj> directly in GAP, as if `GAP.EvalString("<obj>")` was called.
Can be used for creating GAP literals directly from Julia.
julia> @gap (1,2,3)
GAP: (1,2,3)
julia> @gap SymmetricGroup(3)
GAP: SymmetricGroup( [ 1 .. 3 ] )
julia> @gap(SymmetricGroup)(3)
GAP: SymmetricGroup( [ 1 .. 3 ] )
Note that the last two examples have a slight syntactical, and therefore also
a semantical difference. The first one executes the string `SymmetricGroup(3)`
directly inside GAP. The second example returns the function `SymmetricGroup`
via `@gap(SymmetricGroup)`, then calls that function with the argument `3`.
"""
macro gap(str)
return EvalString(string(str))
end

export @gap

"""
LoadPackageAndExposeGlobals(package::String, mod::String; all_globals::Bool = false)
LoadPackageAndExposeGlobals(package::String, mod::Module = Main; all_globals::Bool = false)
Expand Down Expand Up @@ -174,17 +149,3 @@ function Display(x::MPtr)
error("variable was not correctly evaluated")
end
end

"""
macro g_str
Allows to create a GAP string by typing g"content".
julia> g"foo"
GAP: "foo"
"""
macro g_str(str)
return julia_to_gap(str)
end

export @g_str
1 change: 1 addition & 0 deletions pkg/GAPJulia/JuliaInterface/julia/libgap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ const MPtr = Main.ForeignGAP.MPtr

include( "ccalls.jl" )
include( "gap.jl" )
include( "macros.jl" )
include( "gap_to_julia.jl" )
include( "julia_to_gap.jl" )
39 changes: 39 additions & 0 deletions pkg/GAPJulia/JuliaInterface/julia/macros.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
@gap <obj>
@gap(<obj>)
Executes <obj> directly in GAP, as if `GAP.EvalString("<obj>")` was called.
Can be used for creating GAP literals directly from Julia.
julia> @gap (1,2,3)
GAP: (1,2,3)
julia> @gap SymmetricGroup(3)
GAP: SymmetricGroup( [ 1 .. 3 ] )
julia> @gap(SymmetricGroup)(3)
GAP: SymmetricGroup( [ 1 .. 3 ] )
Note that the last two examples have a slight syntactical, and therefore also
a semantical difference. The first one executes the string `SymmetricGroup(3)`
directly inside GAP. The second example returns the function `SymmetricGroup`
via `@gap(SymmetricGroup)`, then calls that function with the argument `3`.
"""
macro gap(str)
return EvalString(string(str))
end

export @gap


"""
macro g_str
Allows to create a GAP string by typing g"content".
julia> g"foo"
GAP: "foo"
"""
macro g_str(str)
return julia_to_gap(str)
end

export @g_str
File renamed without changes.
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ using GAP
include("basics.jl")
include("convenience.jl")
include("conversion.jl")
include("compat.jl")
include("macros.jl")

0 comments on commit 52be909

Please sign in to comment.