Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to generate GAP functions from Julia #212

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/GAPJulia/JuliaInterface/julia/ccalls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ function ElmList(x::MPtr,position)
return GET_FROM_GAP(o)
end

function NewJuliaFunc(x::Function)
o = ccall( :NewJuliaFunc,
MPtr,
(Any,),
x )
return o
end

"""
(func::MPtr)(args...)

Expand Down
2 changes: 2 additions & 0 deletions pkg/GAPJulia/JuliaInterface/julia/julia_to_gap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ function julia_to_gap(obj::Dict{T,S}, recursive::Val{Recursive}=Val(false), recu
return record
end

julia_to_gap(func::Function) = NewJuliaFunc(func)


## TODO: BitArray <-> blist; ranges; ...
8 changes: 8 additions & 0 deletions test/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,12 @@ end
xx = GAP.EvalString( "[1,,1]" )
@test GAP.julia_to_gap([1,nothing,1]) == xx

## Test function conversion
return_first(args...) = args[1]
return_first_gap = GAP.julia_to_gap(return_first)
@test GAP.Globals.IsFunction(return_first) == false
@test GAP.Globals.IsFunction(return_first_gap) == true
list = GAP.EvalString("[1,2,3]")
@test GAP.Globals.List(list,return_first_gap) == list
sebasguts marked this conversation as resolved.
Show resolved Hide resolved

end