Skip to content

Commit

Permalink
kernel: move FUNC_BODY_SIZE to calls.c
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Apr 12, 2019
1 parent cada18f commit e787b8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
16 changes: 15 additions & 1 deletion src/calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,17 @@ Int IsKernelFunction(Obj func)
(SIZE_OBJ(BODY_FUNC(func)) == sizeof(BodyHeader));
}


/* Returns a measure of the size of a GAP function */
static Obj FuncFUNC_BODY_SIZE(Obj self, Obj func)
{
RequireFunction("FUNC_BODY_SIZE", func);
Obj body = BODY_FUNC(func);
if (body == 0)
return INTOBJ_INT(0);
return ObjInt_UInt(SIZE_BAG(body));
}

#ifdef USE_GASMAN

static void SaveHandler(ObjFunc hdlr)
Expand Down Expand Up @@ -1671,7 +1682,7 @@ static StructGVarOper GVarOpers [] = {
**
*V GVarFuncs . . . . . . . . . . . . . . . . . . list of functions to export
*/
static StructGVarFunc GVarFuncs [] = {
static StructGVarFunc GVarFuncs[] = {

GVAR_FUNC(CLEAR_PROFILE_FUNC, 1, "func"),
GVAR_FUNC(IS_PROFILED_FUNC, 1, "func"),
Expand All @@ -1682,6 +1693,9 @@ static StructGVarFunc GVarFuncs [] = {
GVAR_FUNC(LOCATION_FUNC, 1, "func"),
GVAR_FUNC(STARTLINE_FUNC, 1, "func"),
GVAR_FUNC(ENDLINE_FUNC, 1, "func"),

GVAR_FUNC(FUNC_BODY_SIZE, 1, "func"),

{ 0, 0, 0, 0, 0 }

};
Expand Down
13 changes: 1 addition & 12 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ static Obj FuncTNAM_OBJ(Obj self, Obj obj)
*/
static Obj FuncOBJ_HANDLE(Obj self, Obj handle)
{
if (handle != INTPOST_INT(0) && !IS_POS_INT(handle))
if (handle != INTOBJ_INT(0) && !IS_POS_INT(handle))
RequireArgument("OBJ_HANDLE", handle,
"must be a non-negative integer");
return (Obj)UInt_ObjInt(handle);
Expand Down Expand Up @@ -1123,16 +1123,6 @@ static Obj FuncMASTER_POINTER_NUMBER(Obj self, Obj o)
#endif
}

/* Returns a measure of the size of a GAP function */
static Obj FuncFUNC_BODY_SIZE(Obj self, Obj f)
{
Obj body;
if (TNUM_OBJ(f) != T_FUNCTION) return Fail;
body = BODY_FUNC(f);
if (body == 0) return INTOBJ_INT(0);
else return ObjInt_UInt( SIZE_BAG( body ) );
}

/****************************************************************************
**
*F FuncSleep( <self>, <secs> )
Expand Down Expand Up @@ -1525,7 +1515,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC(THREAD_UI, 0, ""),
#endif
GVAR_FUNC(MASTER_POINTER_NUMBER, 1, "ob"),
GVAR_FUNC(FUNC_BODY_SIZE, 1, "f"),
GVAR_FUNC(BREAKPOINT, 1, "integer"),
GVAR_FUNC(UPDATE_STAT, 2, "string, object"),
{ 0, 0, 0, 0, 0 }
Expand Down
4 changes: 3 additions & 1 deletion tst/testinstall/kernel/gap.tst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ gap> MASTER_POINTER_NUMBER(Z(2));
#
gap> FUNC_BODY_SIZE(fail);
fail
Error, FUNC_BODY_SIZE: <func> must be a function (not the value 'fail')
gap> FUNC_BODY_SIZE(SHELL) / GAPInfo.BytesPerVariable;
4
#
gap> Sleep(fail);
Expand Down

0 comments on commit e787b8c

Please sign in to comment.