Skip to content

Commit

Permalink
Remove unused code from GAP interface
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Apr 10, 2023
1 parent 27b077e commit c99e1aa
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 76 deletions.
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, "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

0 comments on commit c99e1aa

Please sign in to comment.