From 9886081b53bc1a68d944d5685bebba8f9ce53e3e Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 12 Apr 2019 12:47:57 +0200 Subject: [PATCH] kernel: add SetPrintObjIndex helper This then allows us to move PrintObjIndex from the global GAPState struct to the ObjectsModuleState struct. --- src/gapstate.h | 1 - src/lists.c | 2 +- src/objects.c | 25 +++++++++++++++---------- src/objects.h | 2 ++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/gapstate.h b/src/gapstate.h index 0aa469b384..13cca3835c 100644 --- a/src/gapstate.h +++ b/src/gapstate.h @@ -101,7 +101,6 @@ typedef struct GAPState { // that use GAP as a library to handle errors /* From objects.c */ - Int PrintObjIndex; Int PrintObjDepth; /* From info.c */ diff --git a/src/lists.c b/src/lists.c index d8711d279d..659cb6508a 100644 --- a/src/lists.c +++ b/src/lists.c @@ -1759,7 +1759,7 @@ static void PrintListDefault(Obj list) if ( elm != 0 ) { if (1 < i) Pr("%<,%< %2>", 0L, 0L); - STATE(PrintObjIndex) = i; + SetPrintObjIndex(i); PrintObj( elm ); } else { diff --git a/src/objects.c b/src/objects.c index 4a117e3c25..1ec0bfd913 100644 --- a/src/objects.c +++ b/src/objects.c @@ -47,6 +47,7 @@ static ModuleStateOffset ObjectsStateOffset = -1; typedef struct { Obj PrintObjThis; + Int PrintObjIndex; #if defined(HPCGAP) Obj PrintObjThissObj; Obj * PrintObjThiss; @@ -920,14 +921,14 @@ void PrintObj ( if ( !fromview && 0 < STATE(PrintObjDepth) ) { os->PrintObjThiss[STATE(PrintObjDepth)-1] = os->PrintObjThis; - os->PrintObjIndices[STATE(PrintObjDepth)-1] = STATE(PrintObjIndex); + os->PrintObjIndices[STATE(PrintObjDepth)-1] = os->PrintObjIndex; } /* handle the */ if (!fromview) { STATE(PrintObjDepth) += 1; os->PrintObjThis = obj; - STATE(PrintObjIndex) = 0; + os->PrintObjIndex = 0; } /* dispatch to the appropriate printing function */ @@ -958,7 +959,7 @@ void PrintObj ( /* if is a subobject, then restore and unmark the superobject*/ if ( 0 < STATE(PrintObjDepth) ) { os->PrintObjThis = os->PrintObjThiss[STATE(PrintObjDepth)-1]; - STATE(PrintObjIndex) = os->PrintObjIndices[STATE(PrintObjDepth)-1]; + os->PrintObjIndex = os->PrintObjIndices[STATE(PrintObjDepth)-1]; } } LastPV = lastPV; @@ -1002,11 +1003,15 @@ static Obj PrintObjHandler(Obj self, Obj obj) } -static Obj FuncSET_PRINT_OBJ_INDEX(Obj self, Obj ind) +void SetPrintObjIndex(Int index) { - if (IS_INTOBJ(ind)) - STATE(PrintObjIndex) = INT_INTOBJ(ind); - return 0; + MODULE_STATE(Objects).PrintObjIndex = index; +} + +static Obj FuncSET_PRINT_OBJ_INDEX(Obj self, Obj index) +{ + SetPrintObjIndex(GetSmallInt("SET_PRINT_OBJ_INDEX", index)); + return 0; } @@ -1051,13 +1056,13 @@ void ViewObj ( if ( 0 < STATE(PrintObjDepth) ) { os->PrintObjThiss[STATE(PrintObjDepth)-1] = os->PrintObjThis; - os->PrintObjIndices[STATE(PrintObjDepth)-1] = STATE(PrintObjIndex); + os->PrintObjIndices[STATE(PrintObjDepth)-1] = os->PrintObjIndex; } /* handle the */ STATE(PrintObjDepth) += 1; os->PrintObjThis = obj; - STATE(PrintObjIndex) = 0; + os->PrintObjIndex = 0; /* dispatch to the appropriate viewing function */ @@ -1086,7 +1091,7 @@ void ViewObj ( /* if is a subobject, then restore and unmark the superobject */ if ( 0 < STATE(PrintObjDepth) ) { os->PrintObjThis = os->PrintObjThiss[STATE(PrintObjDepth)-1]; - STATE(PrintObjIndex) = os->PrintObjIndices[STATE(PrintObjDepth)-1]; + os->PrintObjIndex = os->PrintObjIndices[STATE(PrintObjDepth)-1]; } LastPV = lastPV; diff --git a/src/objects.h b/src/objects.h index 91fefe5e94..abae8e31c8 100644 --- a/src/objects.h +++ b/src/objects.h @@ -757,6 +757,8 @@ void PrintObj(Obj obj); extern Obj PrintObjOper; +void SetPrintObjIndex(Int index); + /**************************************************************************** **