Skip to content

Commit 5af9711

Browse files
committed
gap: switch to libgap API for GAP function calls
1 parent 1ca4a47 commit 5af9711

File tree

2 files changed

+8
-37
lines changed

2 files changed

+8
-37
lines changed

src/sage/libs/gap/element.pyx

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2488,53 +2488,32 @@ cdef class GapElement_Function(GapElement):
24882488
"""
24892489
cdef Obj result = NULL
24902490
cdef Obj arg_list
2491-
cdef int i, n = len(args)
2491+
cdef int n = len(args)
24922492

2493-
if n > 0:
2493+
if n > 0 and n <= 3:
24942494
libgap = self.parent()
24952495
a = [x if isinstance(x, GapElement) else libgap(x) for x in args]
24962496

24972497
try:
24982498
sig_GAP_Enter()
24992499
sig_on()
25002500
if n == 0:
2501-
result = CALL_0ARGS(self.value)
2501+
result = GAP_CallFunc0Args(self.value)
25022502
elif n == 1:
2503-
result = CALL_1ARGS(self.value,
2503+
result = GAP_CallFunc1Args(self.value,
25042504
(<GapElement>a[0]).value)
25052505
elif n == 2:
2506-
result = CALL_2ARGS(self.value,
2506+
result = GAP_CallFunc2Args(self.value,
25072507
(<GapElement>a[0]).value,
25082508
(<GapElement>a[1]).value)
25092509
elif n == 3:
2510-
result = CALL_3ARGS(self.value,
2510+
result = GAP_CallFunc3Args(self.value,
25112511
(<GapElement>a[0]).value,
25122512
(<GapElement>a[1]).value,
25132513
(<GapElement>a[2]).value)
2514-
elif n == 4:
2515-
result = CALL_4ARGS(self.value,
2516-
(<GapElement>a[0]).value,
2517-
(<GapElement>a[1]).value,
2518-
(<GapElement>a[2]).value,
2519-
(<GapElement>a[3]).value)
2520-
elif n == 5:
2521-
result = CALL_5ARGS(self.value,
2522-
(<GapElement>a[0]).value,
2523-
(<GapElement>a[1]).value,
2524-
(<GapElement>a[2]).value,
2525-
(<GapElement>a[3]).value,
2526-
(<GapElement>a[4]).value)
2527-
elif n == 6:
2528-
result = CALL_6ARGS(self.value,
2529-
(<GapElement>a[0]).value,
2530-
(<GapElement>a[1]).value,
2531-
(<GapElement>a[2]).value,
2532-
(<GapElement>a[3]).value,
2533-
(<GapElement>a[4]).value,
2534-
(<GapElement>a[5]).value)
2535-
elif n >= 7:
2514+
else:
25362515
arg_list = make_gap_list(args)
2537-
result = CALL_XARGS(self.value, arg_list)
2516+
result = GAP_CallFuncList(self.value, arg_list)
25382517
sig_off()
25392518
finally:
25402519
GAP_Leave()

src/sage/libs/gap/gap_includes.pxd

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ cdef extern from "gap/system.h" nogil:
2424

2525
cdef extern from "gap/calls.h" nogil:
2626
bint IS_FUNC(Obj)
27-
Obj CALL_0ARGS(Obj f) # 0 arguments
28-
Obj CALL_1ARGS(Obj f, Obj a1) # 1 argument
29-
Obj CALL_2ARGS(Obj f, Obj a1, Obj a2)
30-
Obj CALL_3ARGS(Obj f, Obj a1, Obj a2, Obj a3)
31-
Obj CALL_4ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4)
32-
Obj CALL_5ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5)
33-
Obj CALL_6ARGS(Obj f, Obj a1, Obj a2, Obj a3, Obj a4, Obj a5, Obj a6)
34-
Obj CALL_XARGS(Obj f, Obj args) # more than 6 arguments
3527

3628

3729
cdef extern from "gap/libgap-api.h" nogil:

0 commit comments

Comments
 (0)