pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2012-10-28
2012-10-28 20:38:31 by Tobias S. Josefowitz <tobij@tobij.de>
a9d8c3b1b80f4db706669cb061877bcd1af69b98 (
24
lines) (+
21
/-
3
)
[
Show
|
Annotate
]
Branch:
7.9
Program.inherits(): accept objects as first argument.
1001:
RETURN implements(prog, api); }
-
/*! @decl int inherits(program child, program parent)
+
/*! @decl int inherits(program
|object
child, program parent)
*! @belongs Program *! *! Returns 1 if @[child] has inherited @[parent]. */ PMOD_EXPORT
-
PIKEFUN int program_inherits(program
parent
, program
child
)
+
PIKEFUN int program_inherits(program
|object
child
, program
parent
)
errname Program.inherits; optflags OPT_TRY_OPTIMIZE; {
-
RETURN low_get_storage(
parent
, child) != -1;
+
if (TYPEOF(*child) == PIKE_T_PROGRAM)
+
RETURN low_get_storage(
child->u.program
,
parent) != -1;
+
else if (TYPEOF(*
child)
== PIKE_T_OBJECT) {
+
struct program *p = child->u.object->prog;
+
+
if (
!
p) RETURN 0;
+
if (SUBTYPEOF(*child)) {
+
p
=
(p
-
>inherits + SUBTYPEOF(*child))->prog;
+
if (p->flags & PROGRAM_USES_PARENT)
+
RETURN 0;
+
} else if ((p->flags & PROGRAM_USES_PARENT)
+
&& PARENT_INFO(child->u.object)->parent
+
&& PARENT_INFO(child->u.object)->parent->prog)
+
RETURN 0;
+
RETURN low_get_storage(p, parent) != -
1;
}
-
+
SIMPLE_ARG_TYPE_ERROR("Program.inherits", 1, "program|object");
+
}
+
/*! @decl string defined(program p) *! @belongs Program *!