Skip to content

Commit

Permalink
More reorganization of gap_includes.pxd.
Browse files Browse the repository at this point in the history
Move the libgap-api.h imports first, and also import basic types from
libgap-api.h (which already #includes gap/system.h).
  • Loading branch information
embray committed Jan 14, 2021
1 parent 6a7d07c commit d381021
Showing 1 changed file with 58 additions and 51 deletions.
109 changes: 58 additions & 51 deletions gappy/gap_includes.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

from libc.stdint cimport uintptr_t, uint8_t, uint16_t, uint32_t, uint64_t

cdef extern from "gap/system.h" nogil:

cdef extern from "gap/libgap-api.h" nogil:
"""
#define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();}
"""

# Basic types
ctypedef char Char
ctypedef int Int
ctypedef uintptr_t UInt
Expand All @@ -22,66 +28,28 @@ cdef extern from "gap/system.h" nogil:
ctypedef uint64_t UInt8
ctypedef void* Obj

# Stack management
cdef void GAP_EnterStack()
cdef void GAP_LeaveStack()
cdef int GAP_Enter() except 0
cdef void sig_GAP_Enter()
cdef void GAP_Leave()
cdef int GAP_Error_Setjmp() except 0

cdef extern from "gap/ariths.h" nogil:
Obj SUM(Obj, Obj)
Obj DIFF(Obj, Obj)
Obj PROD(Obj, Obj)
Obj QUO(Obj, Obj)
Obj POW(Obj, Obj)
Obj MOD(Obj, Obj)
bint EQ(Obj opL, Obj opR)
bint LT(Obj opL, Obj opR)


cdef extern from "gap/bool.h" nogil:
cdef Obj GAP_True "True"
cdef Obj GAP_False "False"


cdef extern from "gap/calls.h" nogil:
bint IS_FUNC(Obj)


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/io.h" nogil:
UInt OpenOutputStream(Obj stream)
UInt CloseOutput()


cdef extern from "gap/libgap-api.h" nogil:
"""
#define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();}
"""
# Initialization
ctypedef void (*GAP_CallbackFunc)()
void GAP_Initialize(int argc, char ** argv,
GAP_CallbackFunc markBagsCallback, GAP_CallbackFunc errorCallback,
int handleSignals)

# Evaluation
Obj GAP_EvalString(const char *) except *
Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *)

# Global variables
void GAP_AssignGlobalVariable(const char *, Obj)
int GAP_CanAssignGlobalVariable(const char *)
Obj GAP_ValueGlobalVariable(const char *)
cdef void GAP_EnterStack()
cdef void GAP_LeaveStack()
cdef int GAP_Enter() except 0
cdef void sig_GAP_Enter()
cdef void GAP_Leave()
cdef int GAP_Error_Setjmp() except 0

# Calls
Obj GAP_CallFuncArray(Obj, UInt, Obj *)
Expand Down Expand Up @@ -117,6 +85,45 @@ cdef extern from "gap/libgap-api.h" nogil:
Obj GAP_NewPrecord(Int)


cdef extern from "gap/ariths.h" nogil:
Obj SUM(Obj, Obj)
Obj DIFF(Obj, Obj)
Obj PROD(Obj, Obj)
Obj QUO(Obj, Obj)
Obj POW(Obj, Obj)
Obj MOD(Obj, Obj)
bint EQ(Obj opL, Obj opR)
bint LT(Obj opL, Obj opR)


cdef extern from "gap/bool.h" nogil:
cdef Obj GAP_True "True"
cdef Obj GAP_False "False"


cdef extern from "gap/calls.h" nogil:
bint IS_FUNC(Obj)


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/io.h" nogil:
UInt OpenOutputStream(Obj stream)
UInt CloseOutput()

cdef extern from "gap/macfloat.h" nogil:
double VAL_MACFLOAT(Obj obj)

Expand Down

0 comments on commit d381021

Please sign in to comment.