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

Remove unused code from GAP interface #35478

Merged
merged 1 commit into from
Apr 23, 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
28 changes: 2 additions & 26 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,6 @@ from sage.groups.perm_gps.permgroup_element cimport PermutationGroupElement
from sage.combinat.permutation import Permutation
from sage.structure.coerce cimport coercion_model as cm

decode_type_number = {
0: 'T_INT (integer)',
T_INTPOS: 'T_INTPOS (positive integer)',
T_INTNEG: 'T_INTNEG (negative integer)',
T_RAT: 'T_RAT (rational number)',
T_CYC: 'T_CYC (universal cyclotomic)',
T_FFE: 'T_FFE (finite field element)',
T_PERM2: 'T_PERM2',
T_PERM4: 'T_PERM4',
T_BOOL: 'T_BOOL',
T_CHAR: 'T_CHAR',
T_FUNCTION: 'T_FUNCTION',
T_PLIST: 'T_PLIST',
T_PLIST_CYC: 'T_PLIST_CYC',
T_BLIST: 'T_BLIST',
T_STRING: 'T_STRING',
T_MACFLOAT: 'T_MACFLOAT (hardware floating point number)',
T_COMOBJ: 'T_COMOBJ (component object)',
T_POSOBJ: 'T_POSOBJ (positional object)',
T_DATOBJ: 'T_DATOBJ (data object)',
T_WPOBJ: 'T_WPOBJ (weak pointer object)',
}

############################################################################
### helper functions to construct lists and records ########################
############################################################################
Expand Down Expand Up @@ -681,11 +658,10 @@ cdef class GapElement(RingElement):

sage: x = libgap(1)
sage: x._type_number()
(0, 'T_INT (integer)')
(0, b'integer')
"""
n = TNUM_OBJ(self.value)
global decode_type_number
name = decode_type_number.get(n, 'unknown')
name = TNAM_OBJ(self.value)
return (n, name)

def __dir__(self):
Expand Down
23 changes: 0 additions & 23 deletions src/sage/libs/gap/gap_includes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,10 @@ cdef extern from "gap/calls.h" nogil:


cdef extern from "gap/gasman.h" nogil:
Obj NewBag "NewBag"(UInt type, UInt size)
void MarkBag(Obj bag)
UInt CollectBags(UInt size, UInt full)


cdef extern from "gap/gasman_intern.h" nogil:
void CallbackForAllBags(void (*func)(Obj))


cdef extern from "gap/gvars.h" nogil:
UInt GVarName "GVarName"(char* name)
void AssGVar "AssGVar"(UInt gvar, Obj val)


cdef extern from "gap/integer.h" nogil:
Int IS_INT(Obj)

Expand Down Expand Up @@ -122,35 +112,22 @@ cdef extern from "gap/objects.h" nogil:
Obj SHALLOW_COPY_OBJ(Obj obj)
Obj CopyObj(Obj obj, int mut)

UInt SIZE_OBJ(Obj obj)
UInt TNUM_OBJ(Obj obj)
char* TNAM_OBJ(Obj obj)

cdef enum TNUM:
T_INT
T_INTPOS
T_INTNEG
T_RAT
T_CYC
T_FFE
T_MACFLOAT
T_PERM2
T_PERM4
T_TRANS2
T_TRANS4
T_PPERM2
T_PPERM4
T_BOOL
T_CHAR
T_FUNCTION
T_PLIST
T_PLIST_CYC
T_BLIST
T_STRING
T_COMOBJ
T_POSOBJ
T_DATOBJ
T_WPOBJ


cdef extern from "gap/permutat.h" nogil:
Expand Down
27 changes: 0 additions & 27 deletions src/sage/libs/gap/util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,6 @@ cdef initialize():
# receive error output
GAP_EvalString(_reset_error_output_cmd)

# Prepare global GAP variable to hold temporary GAP objects
global reference_holder
reference_holder = GVarName("$SAGE_libgap_reference_holder")

# Finished!
_gap_is_initialized = True

Expand Down Expand Up @@ -398,29 +394,6 @@ cdef Obj gap_eval(str gap_string) except? NULL:
sig_off()


###########################################################################
### Helper to protect temporary objects from deletion ######################
############################################################################

# Hold a reference (inside the GAP kernel) to obj so that it doesn't
# get deleted this works by assigning it to a global variable. This is
# very simple, but you can't use it to keep two objects alive. Be
# careful.
cdef UInt reference_holder

cdef void hold_reference(Obj obj):
"""
Hold a reference (inside the GAP kernel) to obj

This ensures that the GAP garbage collector does not delete
``obj``. This works by assigning it to a global variable. This is
very simple, but you can't use it to keep two objects alive. Be
careful.
"""
global reference_holder
AssGVar(reference_holder, obj)


############################################################################
### Error handler ##########################################################
############################################################################
Expand Down