pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:1121:    *! Examples of such objects are instances of @[Thread.MutexKey],    *! and @[Nettle.Cipher.State].    *!    *! @seealso    *! @[backtrace()]    */   PIKECLASS FakeObject    program_flags PROGRAM_CONSTANT;   {    PIKEVAR program prog flags ID_PRIVATE|ID_PROTECTED|ID_HIDDEN; +  PIKEVAR string description flags ID_PROTECTED;    -  PIKEFUN void create(program|function|void prog) +  PIKEFUN void create(program|function|void prog, +  string|void description)    flags ID_PROTECTED;    {    struct program *p = prog ? program_from_svalue(prog):NULL;    do_free_program(THIS->prog);    THIS->prog = p;    if (p) add_ref(p); -  +  if (THIS->description) free_string(THIS->description); +  if ((THIS->description = description)) { +  add_ref(THIS->description);    } -  +  }       PIKEFUN string _sprintf(int c, mapping|void ignored)    flags ID_PROTECTED;    { -  +  if ((c == 'O') && THIS->description) { +  ref_push_string(THIS->description); +  return; +  }    push_text("%O()");    if (THIS->prog) {    ref_push_program(THIS->prog);    } else {    ref_push_program(Pike_fp->current_program);    }    f_sprintf(2);    }   }      /*! @endclass    */    - static struct object *clone_fake_object(struct program *p) + static struct object *clone_fake_object(struct object *o)   { -  if (p) ref_push_program(p); -  else push_undefined(); +  struct program *p = o?o->prog:NULL; +  if (p) { +  ref_push_program(p); +  if (FIND_LFUN(p, LFUN__SPRINTF) != -1) { +  push_int('O'); +  apply_lfun(o, LFUN__SPRINTF, 1); +  return clone_object(FakeObject_program, 2); +  } +  } else { +  push_undefined(); +  }    return clone_object(FakeObject_program, 1);   }      /*! @class BacktraceFrame    */      PIKECLASS backtrace_frame   {    PIKEVAR mixed fun;    PIKEVAR array args;
pike.git/src/builtin.cmod:1554:    struct svalue *s = ITEM(bf->args) + i;    if ((TYPEOF(*s) == T_OBJECT) &&    s->u.object->prog &&    (s->u.object->prog->flags &    (PROGRAM_DESTRUCT_IMMEDIATE|PROGRAM_CLEAR_STORAGE))) {    /* It is typically a bad idea to have extra references    * to objects with these flags. The flags are usually    * used by stuff like mutex keys and encryption keys    * respectively.    */ -  struct object *o = clone_fake_object(s->u.object->prog); +  struct object *o = clone_fake_object(s->u.object);    free_object(s->u.object);    SET_SVAL(*s, T_OBJECT, 0, object, o);    }    }    }    }    }    }    res->type_field = BIT_OBJECT;    /* NOTE: res has already been pushed on the stack. */