diff --git a/src/calls.c b/src/calls.c index a67d03f646..d2694d39ba 100644 --- a/src/calls.c +++ b/src/calls.c @@ -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) @@ -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"), @@ -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 } }; diff --git a/src/gap.c b/src/gap.c index 5e0b745535..409df5a3cf 100644 --- a/src/gap.c +++ b/src/gap.c @@ -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); @@ -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( , ) @@ -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 } diff --git a/tst/testinstall/kernel/gap.tst b/tst/testinstall/kernel/gap.tst index fba24c1800..334d4cecf0 100644 --- a/tst/testinstall/kernel/gap.tst +++ b/tst/testinstall/kernel/gap.tst @@ -164,7 +164,9 @@ gap> MASTER_POINTER_NUMBER(Z(2)); # gap> FUNC_BODY_SIZE(fail); -fail +Error, FUNC_BODY_SIZE: must be a function (not the value 'fail') +gap> FUNC_BODY_SIZE(SHELL) / GAPInfo.BytesPerVariable; +4 # gap> Sleep(fail);