pike.git / src / builtin.cmod

version» Context lines:

pike.git/src/builtin.cmod:6127:   {    CVAR struct pike_list_node *head;    CVAR INT32 head_sentinel_refs;    CVAR struct pike_list_node *tail; /* Always NULL. */    CVAR INT32 tail_sentinel_refs;    CVAR struct pike_list_node *tail_pred;    CVAR INT32 num_elems;      #define HEAD_SENTINEL(this) ((struct pike_list_node *)(&this->head))   #define TAIL_SENTINEL(this) ((struct pike_list_node *)(&this->tail)) + #define HEAD_TO_LIST(headptr) ((struct List_struct *)headptr) + #define TAIL_TO_LIST(tailptr) ((struct List_struct *) \ +  (((char *)tailptr) - \ +  OFFSETOF(List_struct, tail)))       /* Sentinel overlap description:    *    * List Head sentinel Tail sentinel    * head next    * head_sentinel_refs refs    * tail prev next    * tail_sentinel_refs refs    * tail_pred prev    */
pike.git/src/builtin.cmod:6551:    program_flags PROGRAM_USES_PARENT;    flags ID_PROTECTED;    {    CVAR struct pike_list_node *cur;    CVAR INT32 ind; /* Not meaningful, but requred by the API. */       /* NOTE: cur may never refer to an unlinked node.    * cur may however refer to a detached node, or to sentinels.    */    -  static struct List_struct *List__get_iterator_find_parent() +  static struct List_struct *List__get_iterator_find_parent(void)    {    struct external_variable_context loc;       loc.o = Pike_fp->current_object;    loc.parent_identifier = Pike_fp->fun;    loc.inherit = Pike_fp->context;    find_external_context(&loc, 1);    return (struct List_struct *)(loc.o->storage +    loc.inherit->storage_offset);    }       INIT    { -  add_ref(THIS->cur = List__get_iterator_find_parent()->head); +  add_ref(THIS->cur = HEAD_SENTINEL(List__get_iterator_find_parent()));    THIS->ind = 0;    }       EXIT    gc_trivial;    {    if (THIS->cur) {    free_list_node(THIS->cur);    THIS->cur = NULL;    }
pike.git/src/builtin.cmod:6796:    pop_n_elems(args);       /* Find our parent. */    loc.o = Pike_fp->current_object;    loc.parent_identifier = Pike_fp->fun;    loc.inherit = INHERIT_FROM_INT(loc.o->prog, loc.parent_identifier);    find_external_context(&loc, 1);    parent = (struct List_struct *)(loc.o->storage +    loc.inherit->storage_offset);    free_list_node(THIS->cur); -  add_ref(THIS->cur = parent->head); +  add_ref(THIS->cur = HEAD_SENTINEL(parent));    THIS->ind = 0;    pop_n_elems(args); -  if (THIS->cur->next) { +  if (parent->head->next) {    push_int(1);    } else {    push_undefined();    }    }    -  /*! @decl protected int(0..1) _iterator_next() +  /*! @decl protected mixed _iterator_next()    *!    *! Advance to the next element in the list.    *!    *! @returns -  *! Returns @expr{1@} on success, and @expr{0@} (zero) +  *! Returns the new element on success, and @[UNDEFINED]    *! at the end of the list.    *!    *! @seealso    *! @[prev()]    */ -  PIKEFUN int(0..1) _iterator_next() +  PIKEFUN mixed _iterator_next()    flags ID_PROTECTED;    {    struct pike_list_node *next;    if ((next = THIS->cur->next)) {    free_list_node(THIS->cur);    add_ref(THIS->cur = next);    THIS->ind++; -  if (next->next) -  RETURN 1; +  } else { +  /* We are at the tail sentinel. */ +  next = TAIL_TO_LIST(THIS->cur)->head; +  free_list_node(THIS->cur); +  add_ref(THIS->cur = next); +  THIS->ind = 0;    } -  RETURN 0; +  if (next->next) { +  push_svalue(&next->val); +  } else { +  push_undefined();    } -  +  }       /*! @decl int(0..1) next()    *!    *! Advance to the next element in the list.    *!    *! @returns    *! Returns @expr{1@} on success, and @expr{0@} (zero)    *! at the end of the list.    *!    *! @seealso