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