pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:994:    *! Returns 1 if @[prog] implements @[api].    */   PMOD_EXPORT   PIKEFUN int program_implements(program prog, program api)    errname Program.implements;    optflags OPT_TRY_OPTIMIZE;   {    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    *!    *! Returns a string with filename and linenumber describing where    *! the program @[p] was defined.    *!    *! The returned string is of the format @expr{"filename:linenumber"@}.    *!    *! If it cannot be determined where the program was defined, @expr{0@}    *! (zero) will be returned.