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

Replace C call to julia_gap by Julia call to _GAP_TO_JULIA #918

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 2 additions & 5 deletions pkg/JuliaInterface/src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ typedef struct {
// Helper used to call GAP functions from Julia.
//
// This function is used by GAP.jl
jl_value_t * call_gap_func(Obj func, jl_value_t * args)
Obj call_gap_func(Obj func, jl_value_t * args)
{
if (!jl_is_tuple(args))
jl_error("<args> must be a tuple");
Expand Down Expand Up @@ -74,10 +74,7 @@ jl_value_t * call_gap_func(Obj func, jl_value_t * args)
return_value = CallFuncList(func, arg_list);
}
END_GAP_SYNC();
if (return_value == NULL) {
return jl_nothing;
}
return julia_gap(return_value);
return return_value;
}


Expand Down
19 changes: 10 additions & 9 deletions src/ccalls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,11 @@ end
# specialize call_gap_func for the no-keywords case, for performance
function call_gap_func_nokw(func::GapObj, args...)
if TNUM_OBJ(func) == T_FUNCTION && length(args) <= 6
_call_gap_func(func, args...)
ret = _call_gap_func(func, args...)
else
ccall((:call_gap_func, JuliaInterface_path()), Any, (Any, Any), func, args)
ret = ccall((:call_gap_func, JuliaInterface_path()), Ptr{Cvoid}, (Any, Any), func, args)
end
return _GAP_TO_JULIA(ret)
end

# make all GapObj callable
Expand All @@ -307,7 +308,7 @@ end
function _call_gap_func(func::GapObj)
fptr = GET_FUNC_PTR(func, 0)
ret = ccall(fptr, Ptr{Cvoid}, (Ptr{Cvoid},), pointer_from_objref(func))
return _GAP_TO_JULIA(ret)
return ret
end

# 1 argument
Expand All @@ -320,7 +321,7 @@ function _call_gap_func(func::GapObj, a1)
pointer_from_objref(func),
_JULIA_TO_GAP(a1),
)
return _GAP_TO_JULIA(ret)
return ret
end

# 2 arguments
Expand All @@ -334,7 +335,7 @@ function _call_gap_func(func::GapObj, a1, a2)
_JULIA_TO_GAP(a1),
_JULIA_TO_GAP(a2),
)
return _GAP_TO_JULIA(ret)
return ret
end

# 3 arguments
Expand All @@ -349,7 +350,7 @@ function _call_gap_func(func::GapObj, a1, a2, a3)
_JULIA_TO_GAP(a2),
_JULIA_TO_GAP(a3),
)
return _GAP_TO_JULIA(ret)
return ret
end

# 4 arguments
Expand All @@ -365,7 +366,7 @@ function _call_gap_func(func::GapObj, a1, a2, a3, a4)
_JULIA_TO_GAP(a3),
_JULIA_TO_GAP(a4),
)
return _GAP_TO_JULIA(ret)
return ret
end

# 5 arguments
Expand All @@ -382,7 +383,7 @@ function _call_gap_func(func::GapObj, a1, a2, a3, a4, a5)
_JULIA_TO_GAP(a4),
_JULIA_TO_GAP(a5),
)
return _GAP_TO_JULIA(ret)
return ret
end

# 6 arguments
Expand All @@ -408,5 +409,5 @@ function _call_gap_func(func::GapObj, a1, a2, a3, a4, a5, a6)
_JULIA_TO_GAP(a5),
_JULIA_TO_GAP(a6),
)
return _GAP_TO_JULIA(ret)
return ret
end