mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 22:10:21 +02:00
slight scm_procedure_p, scm_i_procedure_arity refactor
* libguile/procs.c (scm_procedure_p): * libguile/procprop.c (scm_i_procedure_arity): Refactor.
This commit is contained in:
parent
cf4c26625b
commit
8b33752be7
2 changed files with 13 additions and 27 deletions
|
@ -48,23 +48,20 @@ scm_i_procedure_arity (SCM proc, int *req, int *opt, int *rest)
|
|||
{
|
||||
while (!SCM_PROGRAM_P (proc))
|
||||
{
|
||||
if (SCM_IMP (proc))
|
||||
return 0;
|
||||
switch (SCM_TYP7 (proc))
|
||||
if (SCM_STRUCTP (proc))
|
||||
{
|
||||
case scm_tc7_smob:
|
||||
if (!SCM_SMOB_APPLICABLE_P (proc))
|
||||
return 0;
|
||||
proc = scm_i_smob_apply_trampoline (proc);
|
||||
break;
|
||||
case scm_tcs_struct:
|
||||
if (!SCM_STRUCT_APPLICABLE_P (proc))
|
||||
return 0;
|
||||
proc = SCM_STRUCT_PROCEDURE (proc);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
else if (SCM_HAS_TYP7 (proc, scm_tc7_smob))
|
||||
{
|
||||
if (!SCM_SMOB_APPLICABLE_P (proc))
|
||||
return 0;
|
||||
proc = scm_i_smob_apply_trampoline (proc);
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return scm_i_program_arity (proc, req, opt, rest);
|
||||
}
|
||||
|
|
|
@ -46,21 +46,10 @@ SCM_DEFINE (scm_procedure_p, "procedure?", 1, 0, 0,
|
|||
"Return @code{#t} if @var{obj} is a procedure.")
|
||||
#define FUNC_NAME s_scm_procedure_p
|
||||
{
|
||||
if (SCM_NIMP (obj))
|
||||
switch (SCM_TYP7 (obj))
|
||||
{
|
||||
case scm_tcs_struct:
|
||||
if (!((SCM_OBJ_CLASS_FLAGS (obj) & SCM_CLASSF_PURE_GENERIC)
|
||||
|| SCM_STRUCT_APPLICABLE_P (obj)))
|
||||
break;
|
||||
case scm_tc7_program:
|
||||
return SCM_BOOL_T;
|
||||
case scm_tc7_smob:
|
||||
return scm_from_bool (SCM_SMOB_DESCRIPTOR (obj).apply);
|
||||
default:
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
return SCM_BOOL_F;
|
||||
return scm_from_bool (SCM_PROGRAM_P (obj)
|
||||
|| (SCM_STRUCTP (obj) && SCM_STRUCT_APPLICABLE_P (obj))
|
||||
|| (SCM_HAS_TYP7 (obj, scm_tc7_smob)
|
||||
&& SCM_SMOB_APPLICABLE_P (obj)));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue