2 * Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
27 * Typemaps for lists of dumpspecs
30 * %include "amglue/dumpspecs.swg"
31 * %import "Amanda/Logfile.swg"
32 * and declare functions as either taking or returning "amglue_dumpspec_list *".
36 typedef GSList amglue_dumpspec_list;
39 /* Typemap to convert a GSList of dumpspec_t's into an array of same. This uses
40 * some SWIG trickery to manage to convert the GSList itself to an array, while
41 * leaving the dumpspecs as C objects.
44 %typemap(out) amglue_dumpspec_list * {
47 EXTEND(SP, g_slist_length($1)); /* make room for return values */
51 /* Let SWIG take ownership of the object; we'll free the GSList momentarily */
52 $result = SWIG_NewPointerObj(iter->data, $descriptor(dumpspec_t*), SWIG_OWNER | SWIG_SHADOW);
57 /* Now free the GSList, but *not* its contents (which are now "owned" by SWIG) */
62 /* Typemap to convert an arrayref of dumpspecs into a GSList of same. This assumes
63 * that the dumpspecs are all C objects. This borrows references to the underlying
64 * dumpspec objects, which remain owned by SWIG.
66 %typemap(in) amglue_dumpspec_list * {
71 if (!SvROK($input) || SvTYPE(SvRV($input)) != SVt_PVAV) {
72 SWIG_exception_fail(SWIG_TypeError, "Expected an arrayref of dumpspecs");
74 av = (AV *)SvRV($input);
78 for (i = 0; i < len; i++) {
79 dumpspec_t *ds = NULL;
80 SV **elt = av_fetch(av, i, 0);
82 SWIG_ConvertPtr(*elt, (void **)&ds, $descriptor(dumpspec_t *), 0);
84 SWIG_exception_fail(SWIG_TypeError, "Expected an arrayref of dumpspecs");
85 $1 = g_slist_append($1, ds);
89 %typemap(freearg) amglue_dumpspec_list * {
90 /* Free the GSList, but not its contents (which are still owned by SWIG) */