/* -*- c -*-

    This file is part of GPCT.

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 3 of the
    License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    02110-1301 USA

    Copyright Alexandre Becoulet <alexandre.becoulet@free.fr> (C) 2009

    As a special exception, if other file access functions, variables
    or types which are instanciated by direct invocation of a GPCT
    macro from source code covered by the GNU LGPL version 2 or
    later, the file does not by itself cause the resulting work to
    be covered by the GNU General Public License. However the source
    code for this file must still be made available in accordance
    with section (3) of the GNU General Public License. This
    exception does not invalidate any other reasons why a work based
    on this file might be covered by the GNU General Public License.

    Default array_push*, array_pop* implementation functions

*/

#ifndef GPCT_PUSHPOP_ARRAY_H_
#define GPCT_PUSHPOP_ARRAY_H_

/* backslash-region-begin */
#define GPCT_CONT_PUSHPOP_ARRAY_FUNC(attr, name, prefix,
                                     prefixback, lockname)

attr GPCT_CONT_PROTO_PUSH_ARRAY(name, prefix)
{
  uintptr_t     i;

  for (i = 0; i < size; i++)
    prefix##_push(root, item[i]);

  return size;
}

attr GPCT_CONT_PROTO_POP_ARRAY(name, prefix)
{
  uintptr_t     i;

  for (i = 0; i < size; i++)
    item[i] = prefix##_pop(root);

  return size;
}

attr GPCT_CONT_PROTO_PUSHBACK_ARRAY(name, prefix)
{
  uintptr_t     i;

  for (i = 0; i < size; i++)
    prefixback##_pushback(root, item[i]);

  return size;
}

attr GPCT_CONT_PROTO_POPBACK_ARRAY(name, prefix)
{
  uintptr_t     i;

  for (i = 0; i < size; i++)
    item[i] = prefixback##_popback(root);

  return size;
}
/* backslash-region-end */


#endif

