pike.git/
src/
builtin_functions.c
Branch:
Tag:
Non-build tags
All tags
No tags
2015-12-14
2015-12-14 14:29:51 by Martin Nilsson <nilsson@fastmail.com>
4799249b074f4cc538013f2dc67c3b3369afc2fd (
44
lines) (+
25
/-
19
)
[
Show
|
Annotate
]
Branch:
8.1
Only need to check cyclic for arrays.
4756:
PMOD_EXPORT int callablep(struct svalue *s) {
-
int ret = 0;
-
DECLARE_CYCLIC();
-
-
if (BEGIN_CYCLIC(s, NULL)) {
-
END_CYCLIC();
-
return 1;
-
}
-
-
SET_CYCLIC_RET((ptrdiff_t)1);
-
+
switch( TYPEOF(*s) ) { case T_FUNCTION: if( SUBTYPEOF(*s) == FUNCTION_BUILTIN || s->u.object->prog)
-
ret
=
1;
+
return
1;
break; case T_PROGRAM:
-
ret
=
1;
+
return
1;
break; case T_OBJECT: {
4782:
if((p = s->u.object->prog) && FIND_LFUN(p->inherits[SUBTYPEOF(*s)].prog, LFUN_CALL ) != -1)
-
ret
=
1;
+
return
1;
} break; case T_ARRAY:
-
+
{
+
int ret = 0;
+
DECLARE_CYCLIC();
+
+
if (BEGIN_CYCLIC(s, NULL)) {
+
END_CYCLIC();
+
return 1;
+
}
+
+
SET_CYCLIC_RET((ptrdiff_t)1);
+
array_fix_type_field(s->u.array); if( !s->u.array->type_field) { ret = 1;
-
break;
+
}
-
if( !(s->u.array->type_field & ~(BIT_CALLABLE|BIT_INT)) ) {
+
else
if( !(s->u.array->type_field & ~(BIT_CALLABLE|BIT_INT)) ) {
struct array *a = s->u.array; int i; ret = 1; for(i=0; i<a->size; i++) if( TYPEOF(ITEM(a)[i])!=T_INT && !callablep(&ITEM(a)[i]) )
-
+
{
ret = 0;
-
}
+
break; }
-
+
}
END_CYCLIC(); return ret;
-
+
break;
}
-
+
}
-
+
return 0;
+
}
+
/*! @decl int callablep(mixed arg) *! *! Returns @expr{1@} if @[arg] is a callable, @expr{0@} (zero) otherwise.